echoindia756 Posted March 12, 2009 Share Posted March 12, 2009 Hi there, I'm having a bit of trouble getting something to work. Basically, I have several fields in a table: "Item Name" and "Item Price" These values are dynamic to each user (so different items will appear depending on your username), I want to retrieve this information from the database row and put it into a HTML table on the users homepage on my website So for example the data would appear like this: Item Name Item Price Digital Camera €40.00 Underwater Camera €50.00 So I think the mysql query would be something like: mysql_query("SELECT * FROM table_name WHERE user_id = $_SESSION['user_id']"); But i'm not sure how to get all the users items to display on the table, could someone help me with the PHP code please? I'd really appreciate it! Thanks in advance! Quote Link to comment Share on other sites More sharing options...
echoindia756 Posted March 12, 2009 Author Share Posted March 12, 2009 anyone any ideas? Quote Link to comment Share on other sites More sharing options...
lonewolf217 Posted March 12, 2009 Share Posted March 12, 2009 <?php $query = mysql_query("SELECT * FROM table_name WHERE user_id = $_SESSION['user_id']"); while($row = $mysql_fetch_array($query)) { echo $row['Item Name'] . " " . $row['Item Price']; } Quote Link to comment Share on other sites More sharing options...
echoindia756 Posted March 13, 2009 Author Share Posted March 13, 2009 Hi thanks for that! I think I almost got it working, the problem I am having now is that if there is more than one row in the table, it only displays one of the rows on the html table, is there anyway to display all of the rows that are in the table? Many thanks for your help. Quote Link to comment Share on other sites More sharing options...
echoindia756 Posted March 13, 2009 Author Share Posted March 13, 2009 Anyone any ideas? Quote Link to comment Share on other sites More sharing options...
echoindia756 Posted March 13, 2009 Author Share Posted March 13, 2009 anyone got any suggestions please!? 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.