Freedom-n-Democrazy Posted September 30, 2011 Share Posted September 30, 2011 Does anyone know how I can select (all) from a field? Something like: select id from products where category = * I am using it for: if ($_POST['category'] == "(Any)") { $_POST['category'] = "*"; ... then I'd be using: select id from products where category = ".$_POST['category']." Quote Link to comment https://forums.phpfreaks.com/topic/248164-selecting-all-from-a-field/ Share on other sites More sharing options...
Freedom-n-Democrazy Posted September 30, 2011 Author Share Posted September 30, 2011 NOTE: From a specific field, in this case - .category". Quote Link to comment https://forums.phpfreaks.com/topic/248164-selecting-all-from-a-field/#findComment-1274348 Share on other sites More sharing options...
Muddy_Funster Posted September 30, 2011 Share Posted September 30, 2011 you would be better to build the full where clause dependant on the input, rather than the filter placed on the field: if($_POST['category'] == "(Any)"){ $where = ''; } else{ $where = " WHERE category = '{$_POST['category']}'"; } $sql = $sql.$where; Quote Link to comment https://forums.phpfreaks.com/topic/248164-selecting-all-from-a-field/#findComment-1274369 Share on other sites More sharing options...
ManiacDan Posted September 30, 2011 Share Posted September 30, 2011 Leave off the WHERE clause entirely if you want to match all rows. Quote Link to comment https://forums.phpfreaks.com/topic/248164-selecting-all-from-a-field/#findComment-1274396 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.