Jump to content

Print the results of a query


Mr Chris

Recommended Posts

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

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