Greetings,
Currently my code is arranged in this nature, and please excuse me for being so new, I'm learning! :) So no laughing at my echo's as I don't know much about tables yet.
The issue I have is that I am using a while loop to display 5 rows of data from the mysql database. However when I put a submit button in the loop it will loop it 5 times properly but when any of the submit buttons are clicked it will default to the values from the last row of data retrieved.
Here's what I have so far with code.
Currently my code is arranged in this nature, and please excuse me for being so new, I'm learning! :) So no laughing at my echo's as I don't know much about tables yet.
The issue I have is that I am using a while loop to display 5 rows of data from the mysql database. However when I put a submit button in the loop it will loop it 5 times properly but when any of the submit buttons are clicked it will default to the values from the last row of data retrieved.
Here's what I have so far with code.
Code:
$dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
$query = "SELECT * FROM test LIMIT 5";
$data = mysqli_query($dbc, $query);
$form_block = "
<form method=\"post\" action=\"$_SERVER[PHP_SELF]\">
<input type=\"text\" id=\"wq\" name=\"wq\" SIZE = 4 MAXLENGTH = 4>
<input type=\"submit\" value=\"Purchase\" name=\"submit\">
</form>";
while ($row = mysqli_fetch_array($data)) {
echo '<strong>Name: </strong>' . $row['name'];
echo '<br>';
echo '<strong>Attire: </strong>' . $row['wk'];
echo '<strong>Found: </strong>' . $row['wf'];
echo '<br>';
echo '<strong>Purchase Price: </strong>' . $row['wc'] . ' dollars';
echo '<br>';
echo '<strong>Description: </strong>' . $row['wt'];
echo '<br>';
echo "$form_block";
echo '</ P>';
// I'm placing variables here to pull the data for later
}
Comment