View Single Post
  #1 (permalink)  
Old April 29th, 2004, 09:13 AM
skicrud skicrud is offline
Authorized User
 
Join Date: Sep 2003
Location: , , .
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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 ")";
?>