foreach and multi-record forms
Posted: Thu Mar 04, 2004 8:40 am
I am trying to do the following
Pull out a range of data from a pg table
This works
Then put it into a multi record html form
this is my current code
However it only brings the last record repeted several times
Any help much appreciated
Pull out a range of data from a pg table
This works
Then put it into a multi record html form
this is my current code
Code: Select all
<html>
<body>
<?php
$db = pg_connect("dbname=data_cc");
$query = "SELECT * FROM tb_contacts WHERE contact_id<'41'";
$result = pg_exec($db, $query);
if (!$result) {
printf ("ERROR");
$errormessage = pg_errormessage($db);
echo $errormessage;
exit;
}
$numrows = pg_numrows($result);
$row=0;
$myrow = pg_fetch_row ($result,$row);
foreach ($myrow as $value){
printf ("$row");
echo('<form name="contacts" method="POST" action="update1.php">');
echo('<table>');
echo('<tr>');
echo('<td>');
echo('<input type="text" name="id'. $row .'" value="' .$myrow[0] .'">');
echo('<input type="text" name="first name'. $row .'" value="' .$myrow[2] .'">');
echo('</td>');
echo('</tr>');
echo('<tr>');
echo('<td>');
}
?>
<input type='submit' value='Save to Cart'>
</td>
</tr>
</table>
</form>
}
?>
</body>
</html>Any help much appreciated