[thelist] SQL INSERT to UPDATE converter?
sbeam
sbeam at syxyz.net
Mon Nov 15 10:09:41 CST 2004
On Monday 15 November 2004 10:05 am, Rob Smith wrote:
> Convert this INSERT statement into an UPDATE statement:
>
> INSERT INTO myTable (day1,day2,day3......day30,day31) VALUES ('" .
> $_POST["day1"] ."', '" . $_POST["day2"] ."', '" .
$_POST["day3"] ."', ......
> '" . $_POST["day30"] ."','" . $_POST["day31"] ."')
>
> The ...... represent the respective days 4 throught 29.
Luke, use the for{} loop
$sql = "UPDATE myTable SET ";
for ($i=1; $i<32; $i++) {
$sql .= "day$i = ";
$sql .= addslashes($_POST["day$i"]);
if ($i<31) $sql .= ', ';
}
--
# S Beam - Web App Dev Servs
# http://www.onsetcorps.net/
More information about the thelist
mailing list