MySQL Forums
Forum List  »  PHP

Only can display first row of tables to a form
Posted by: Douglas Moxley
Date: September 06, 2017 05:32PM

Hi fellow coders!

I've been stuck the entire day on the same problem where I can only display the first row to a table or form. I can echo rows fine to the screen but cannot get more than one row into a table, or form. The problem is when I attempt to use a WHILE statement; nothing echos. I've attached a sample page along with screen shots in hopes someone can help. Thank you very much in advance.

NOTE: Oh man, can't add an attachment. Anyway, below is the code.

###############################################

<?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(); }

$first_name = ($_get['first_name']);
$last_name = ($_get['last_name']);

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

$row=mysqli_fetch_array($result); ///////// RETURNS ONE ROW OF RESULTS FINE
// while($row=mysqli_fetch_array($result)( { //////// RETURNS NO ROWS WHEN I USE A LOOP


$row['first_name'];
$row['last_name'];

// } // USED FOR WHILE LOOP

mysqli_free_result($result);
$dbLink->close();

?>

<html>
<body>
<input type="text" name="<?php echo $row['first_name']; ?>" value= "<?php echo $row['first_name']; ?> ">
<input type="text" name="<?php echo $row['last_name']; ?>" value= "<?php echo $row['last_name']; ?> ">
</body>
</html>

########################################

Options: ReplyQuote


Subject
Written By
Posted
Only can display first row of tables to a form
September 06, 2017 05:32PM


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.