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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.