Hi all trying I am trying to display all the rows from a database if the default value is blank I have tried to put a * or ? in the php code for the SQL What could be wrong here? What do I need to put for the variable section for the correct syntax As it its (oh by the way this is dreamweaver and the code is PHP) Name = p Type = numeric Default value = -1 Run-Time value $_Get[‘p’] Cat = is the Variable to select the rows if a value is present $p_Recordset_B = "-1"; if (isset($_GET['p'])) { $p_Recordset_B = (get_magic_quotes_gpc()) ? $_GET['p'] : addslashes($_GET['p']); } SELECT Company FROM Table WHERE Cat = %s <> 'NULL' ORDER BY RAND() LIMIT 70
it is not making any sense Try this SELECT Company FROM Table WHERE Cat = NULL ORDER BY RAND() LIMIT 70 Regards Alex
Or SELECT Company FROM Table WHERE Cat IS NULL ORDER BY RAND() LIMIT 70 if the previous is not working
Ok let me explain a bit more.. Application : Dreamweaver Code : PHP Q): I wish to pass a query using Dreamweaver's internal dialog SQL The result i wish to achieve is that when a parameters is not passed to a variable it would display all the records in the database EG +-------------------------------+ company | cat +-------------------------------+ |abc | 1 |abd | 1 |aba | 2 +-------------------------------+ now if i pass 2 to cat (p)it will display the result of aba if no parameters are passed i would like to see abc adb aba the dreamweaver code has section like this Name = p Type = numeric Default value = -1 " -1 this would be the the default value if no parameters was passed but that would not display anything" Run-Time value $_Get[‘p’] this is a snippet from the dreaweaver code on how it get the value $p_Recordset_B = "-1"; < again here default value which would not display if (isset($_GET['p'])) { $p_Recordset_B = (get_magic_quotes_gpc()) ? $_GET['p'] : addslashes($_GET['p']); } I have the SQL query below and would like to select 70 random names , ignore blank records and it value must come from %s (p) SELECT Company FROM Table WHERE Cat = %s <> 'NULL' ORDER BY RAND() LIMIT 70 do i hack the php code or the sql
u need to hack the php code just put a simple check on top of sql if (%s) { SELECT Company FROM Table WHERE Cat = %s ORDER BY RAND() LIMIT 70 } Regards Alex