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! Link to comment https://forums.phpfreaks.com/topic/149147-getting-data-from-mysql-row-in-the-database-and-displaying-on-web-page/ Share on other sites More sharing options...
echoindia756 Posted March 12, 2009 Author Share Posted March 12, 2009 anyone any ideas? Link to comment https://forums.phpfreaks.com/topic/149147-getting-data-from-mysql-row-in-the-database-and-displaying-on-web-page/#findComment-783184 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']; } Link to comment https://forums.phpfreaks.com/topic/149147-getting-data-from-mysql-row-in-the-database-and-displaying-on-web-page/#findComment-783189 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. Link to comment https://forums.phpfreaks.com/topic/149147-getting-data-from-mysql-row-in-the-database-and-displaying-on-web-page/#findComment-783685 Share on other sites More sharing options...
echoindia756 Posted March 13, 2009 Author Share Posted March 13, 2009 Anyone any ideas? Link to comment https://forums.phpfreaks.com/topic/149147-getting-data-from-mysql-row-in-the-database-and-displaying-on-web-page/#findComment-783770 Share on other sites More sharing options...
echoindia756 Posted March 13, 2009 Author Share Posted March 13, 2009 anyone got any suggestions please!? Link to comment https://forums.phpfreaks.com/topic/149147-getting-data-from-mysql-row-in-the-database-and-displaying-on-web-page/#findComment-783947 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.