Build a dynamitic sql statement
I am using the following code to build a dynamitic sql statement based on all the fields in a table. From here I need to pass in matching values from a form which is also dynamiticly created containing all fields in the table. I can get the name(field1...fieldx) but am not sure how to pass in the field values to value($var1...$varx)
<?php
echo "name(";
$result=mysql_list_fields("msds","msdsmasterlist") ;
for($i=1; $i<mysql_num_fields($result)-1; $i++){
echo mysql_field_name($result,$i);
echo ",";
}
//last field
$result=mysql_list_fields("msds","msdsmasterlist") ;
$lastfield=mysql_num_fields($result)-1;
echo mysql_field_name($result,$lastfield);
//end section
echo ")";
?>
<?php
//echo "<BR><BR><BR>$ADACPartNum,$RevisionDate,$ProductNa me,$ProductDescription<BR><BR><BR>";
echo "value($";
$result=mysql_list_fields("msds","msdsmasterlist") ;
for($i=1; $i<mysql_num_fields($result)-1; $i++){
echo mysql_field_name($result,$i);
echo ",$";
}
//last field
$result=mysql_list_fields("msds","msdsmasterlist") ;
$lastfield=mysql_num_fields($result)-1;
echo mysql_field_name($result,$lastfield);
//end section
echo ")";
?>
|