On Saturday 06 March 2004 03:29, Cory Berry wrote: > Hello, I'm having difficulty dynamically creating a variable name for > mysql_query. > I've tried using variable variables. I tried to re-create the sql string by > $a = "update table set startdate='$startdate" > $a .= $i ." ' where id=$i"); > but that didn't work.
HOW did it not work? Did you print out $a to see that it contained what you thought it should contain? You would've probably found that you had an extra space somewhere. > I'm dynamically creating each name of the input tag. > > My input tag is: name=startdate<?echo id ?> > > but when I use > > $query = mysql_query("select * from table"); > $num_rows = mysql_num_rows($query); > for($i=1;$i<=$num_rows;$i++){ > $updatesql = mysql_query("update table set startdate='$startdate.=$i' where > id=$i"); > } > > It doesn't execute. mysql_error() would tell why a mysql_query() fails. And again printing out the query that is being executed will allow you to see whether it is what you *think* should be executed. BTW I think it would be somewhat easier if you used arrays instead. -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * ------------------------------------------ Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general ------------------------------------------ /* Most people don't need a great deal of love nearly so much as they need a steady supply. */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php