Bazzaah Posted August 8, 2011 Share Posted August 8, 2011 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. Quote Link to comment Share on other sites More sharing options...
WebStyles Posted August 8, 2011 Share Posted August 8, 2011 do you mean this: (?) session_start(); $col = $_SESSION[$column]; $query = "SELECT $col FROM table"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_assoc($result)){ echo $row[$col] ; } Quote Link to comment Share on other sites More sharing options...
voip03 Posted August 8, 2011 Share Posted August 8, 2011 I think Pagination will help you http://www.phpfreaks.com/tutorial/basic-pagination Quote Link to comment Share on other sites More sharing options...
Bazzaah Posted August 8, 2011 Author Share Posted August 8, 2011 Thanks both of you. I'll read through the pagination tutorial. Re the code WebStyles, I've not made that work yet. Is there not just a way that I can use a WHERE clause in the SELECT? Quote Link to comment 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.