p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Pro PHP (http://p2p.wrox.com/forumdisplay.php?f=96)
-   -   Build a dynamitic sql statement (http://p2p.wrox.com/showthread.php?t=12427)

skicrud April 29th, 2004 09:13 AM

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 ")";
?>



All times are GMT -4. The time now is 07:14 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.