Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Pro PHP
| Search | Today's Posts | Mark Forums Read
Pro PHP Advanced PHP coding discussions. Beginning-level questions will be redirected to the Beginning PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old April 29th, 2004, 09:13 AM
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 ")";
?>



Similar Threads
Thread Thread Starter Forum Replies Last Post
convert a SQL Statement from MS Access to a SQL Corey Access 6 March 28th, 2007 12:33 PM
SQL Statement??? carswelljr SQL Server 2000 2 August 25th, 2006 12:40 PM
build switch statement to make dynamic crmpicco Javascript How-To 0 October 27th, 2005 05:44 AM
dynamitic sql statement skicrud PHP Databases 1 April 29th, 2004 02:04 PM
SQL Statement stu9820 ASP.NET 1.0 and 1.1 Basics 1 September 30th, 2003 04:30 PM





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