Mr Chris Posted August 14, 2010 Share Posted August 14, 2010 Hi, say I have a query like so: foreach($_REQUEST['r'] as $position => $row) { $row = implode("', '",$row); $result = mysql_query("Insert into player_stats (position,shirt_number,player_id,goals,cards,substituted,used_sub,injury,season,report_id) values('$position','$row','$currentSeason','$report_id')"); } How do I print the results of that query to my Browser for each time? Thanks Link to comment https://forums.phpfreaks.com/topic/210725-print-the-results-of-a-query/ Share on other sites More sharing options...
Skewled Posted August 14, 2010 Share Posted August 14, 2010 You would do a separate query to get the results and print them. This is an example of how I would do it: // Fill in the information for your database values here: $dbc = mysqli_connect('db_host', 'dbuser', 'dbpassword', 'dbname'); $query = "SELECT * FROM player_stats"; // You could add a condition here WHERE player_id = $playerid"; as an example $data = mysql_query($dbc, $query); while ($row = mysqli_fetch_array($data)) { echo $row['position'] . '<br>'; // Repeat for what you wish to display echo $row['shirt_number'] . '<br>'; echo $row['player_id'] . '<br>'; } Or using what you have and just print that information. // Add this under your values('$position','$row','$currentSeason','$report_id')"); echo "$position position was added.<br>"; echo "$row row was added.<br>"; echo "$currentSeason season was added.<br>"; echo "$report_id report id was added.<br>"; } // close the foreach loop Link to comment https://forums.phpfreaks.com/topic/210725-print-the-results-of-a-query/#findComment-1099281 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.