Jump to content

session variable in WHERE clause


Bazzaah

Recommended Posts

I'd appreciate some help please.

 

I'm using $_SESSION to pass info from a MySQL search to a new page.

 

How do I include the $_SESSION in the SELECT? I've done loads of different combinations - none has worked and I've not found anything to help on Google.

 

In this case;

 

user searches a db table.

Results are returned.

User can click on result to be taken to a new page where columns from the row are displayed

 

Results are displayed on the new page like this;

 

$query = "SELECT * FROM table";  

$result = mysql_query($query) or die(mysql_error());

while($row = mysql_fetch_assoc($result)){

echo $_SESSION[$column] ;

}

 

That code returns the correct column BUT for as many rows there are in the table.

 

How can I  set things up so that column entries are only echoed for the one row that's been selected by the user?

 

Sorry if unclear; happy to clarify if needed - any help would be really appreciated.

Link to comment
https://forums.phpfreaks.com/topic/244197-session-variable-in-where-clause/
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.