Hi everyone,

I'm returning some records from a MySQL table. I'm looping out a name, then an empty text input (which will be used to update the name), and then a price. The SELECT query might return any number of names and prices. Now the problem at the moment is that I can enter new names into the form but only the last name I enter will be added to the table replacing all of the names with the same name. Clearly, I don't want this to happen. Each text input must only replace the name associated with it. Do I need to add some counter (
PHP Code:
name=['name'][$i]; 
) ?

Could someone please help me?



Thank you!!

PHP Code:
if ($num 0) { 
while (
$row mysqli_fetch_array($rMYSQLI_ASSOC)) { 
print
'<p>'.$row['name'].'</p>
<input type="text" name="name" size="" maxlength="" value="'
;
if (isset(
$_POST['name'])) echo $_POST['name'];
print
'"  /> </p>';

print
'<p>'.$row['price'].'</p>';
}
}


if (
$_SERVER['REQUEST_METHOD'] == 'POST') {    
      
$phpdummy mysqli_real_escape_string($dbctrim($_POST['name'])); 
$q "UPDATE  table1 INNER JOIN table2 USING (some_id) SET  name='$phpdummy' WHERE user_id = {$_SESSION['user_id']}  "