MySQL Forums
Forum List  »  PHP

Re: Only can display first row of tables to a form
Posted by: Douglas Moxley
Date: September 07, 2017 02:36PM

Hi Peter,

Discovered why my other entries were not populating. Since I was doing a loop function the line $dbLink->close(); needed to be moved to the end of the script. The below script is working fine now. I really appreciate the help and advice you gave me. You are awesome!


<?php

require('dbconnect_test.php');

$dbLink = new mysqli ($DBHOST, $DBUSER, $DBPASS, $DBNAME);

if (mysqli_connect_errno())
{

echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

$player_first_name = ($_get['player_first_name']);
$player_last_name = ($_get['player_last_name']);


$sql = "SELECT * FROM test_tbl";
$result = mysqli_query ($dbLink, $sql);

while($row=mysqli_fetch_array($result)) {
echo $row['player_first_name'], $row['player_last_name'], "<br />";

?>

<form action="test.php" method="get" enctype="multipart/form-data" multiple="multiple">
<input type="text" name="player_first_name" value= "<?php echo $row['player_first_name']; ?> ">
<input type="text" name="player_last_name" value= "<?php echo $row['player_last_name']; ?> ">
</form>

<?php
}
$dbLink->close();
?>

Options: ReplyQuote


Subject
Written By
Posted
Re: Only can display first row of tables to a form
September 07, 2017 02:36PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.