gple Posted May 30, 2010 Share Posted May 30, 2010 $query="select * from table where id=''" what can I make id equal to so tha I can display anything. I dont want to write a separate sql statement for when id has a value and when it doesnt have a value. Link to comment https://forums.phpfreaks.com/topic/203378-select-statement/ Share on other sites More sharing options...
pornophobic Posted May 30, 2010 Share Posted May 30, 2010 what can I make id equal to so tha I can display anything. I dont want to write a separate sql statement for when id has a value and when it doesnt have a value. Can you be a little more specific? Not trying to be an ass, but I'm having trouble understanding what it is you're wanting to do. From what I understand it'd have to be based on something on one of the other fields if you're not going by id, which makes me wonder if you are using a primary key in your tables? I thought you would need at least one, which is generally a A_I id field... a lot of the time. Link to comment https://forums.phpfreaks.com/topic/203378-select-statement/#findComment-1065460 Share on other sites More sharing options...
shino Posted May 30, 2010 Share Posted May 30, 2010 $query="select * from table where id=''" what can I make id equal to so tha I can display anything. I dont want to write a separate sql statement for when id has a value and when it doesnt have a value. Maybe something like: <?php $query='select * from table where id='.(is_numeric($id) ? $id:'"" OR 1=1'); ?> Link to comment https://forums.phpfreaks.com/topic/203378-select-statement/#findComment-1065484 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.