Jump to content

Select statement


gple

Recommended Posts

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

$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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.