read from two mysql tables into one form
Posted: Thu Mar 29, 2012 8:51 pm
i have a long form with several fields for submission.
i used this code for a long time and it worked great -- if all i needed was data from one table to be fed into the form:
that is the very simple version. in between the '{' and the '}' are hundreds of fields, etc.
but underneath 'b_fname' is another section of the form, and i need it to draw from 'cdata' instead of 'ldata'. and then once it all fills in right, changes made, etc, i submit the entire thing back to update the mysql DB
i tried doing:
but that didn't work
any ideas greatly appreciated
i used this code for a long time and it worked great -- if all i needed was data from one table to be fed into the form:
Code: Select all
<?
include("dbinfo.inc.php");
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$term = $_POST['term'];
$sql = mysql_query("select * from ldata where id = '$term'");
while ($row = mysql_fetch_array($sql))
{
?>
<table><tr><td>
<input type="text" value="<?php echo $row['b_fname'];?>">
<?
}
?>
but underneath 'b_fname' is another section of the form, and i need it to draw from 'cdata' instead of 'ldata'. and then once it all fills in right, changes made, etc, i submit the entire thing back to update the mysql DB
i tried doing:
Code: Select all
<?
include("dbinfo.inc.php");
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$term = $_POST['term'];
$sql = mysql_query("select * from ldata where id = '$term'");
while ($row = mysql_fetch_array($sql))
$sql2 = mysql_query("select * from cdata where id = '$term'");
while ($row2 = mysql_fetch_array($sql2))
{
any ideas greatly appreciated