Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
I would like to insert and then update several data at the same time in a database.
I have this querry I run to get the page on which I run then the "insert / update" querry:Code: Select all
$q = "select * from TABLE_0
WHERE Sold = 'NO'
AND Zip LIKE '$Zip1$Zip2%'
ORDER BY Date asc
LIMIT $Leads_H ";
if(!($res = mysql_DB_query($DB, $q)))
die("ERROR");
$res = mysql_db_query($DB, $q);
$numberOfRows=mysql_num_rows($res);
while ($i > $Leads_H) {
$Q_ID=mysql_result($res,$i,"Q_ID");
echo "<input type='hidden' name='".$r["Q_ID"]."' value=Q_ID[$i]>";
}
while ($r=mysql_fetch_array($res)){
$Q_ID = $_POST[Q_ID][$i];
echo "<input type=hidden name=Q_ID[$i] value=".$r["Q_ID"].">
<td align=left class=black>".$r["Name"]."</td>
<td align=left class=black>".$r["Zip"]."</td>";
++$i;
}
echo "<a href=Command.php>ORDER</a>";<input type=hidden name=Q_ID[1] value=9>
<input type=hidden name=Q_ID[2] value=17>
On the next script (Command.php) I run:
Code: Select all
$q ="insert into TABLE_1 (Company_Name, A2, A3) values ('$Company_Name', '$A2', '$A3')";Code: Select all
$q = "update TABLE_0 set Sold='YES',Company_Name='$A'
WHERE
'Q_ID[$i]' = 'Q_ID[$i]' LIMIT $Leads_H";echo $q;
while ($r=mysql_fetch_array($res)){
$Q_ID = $_POST[Q_ID][$i];
}I do not get any ERROR but this querry updates the first X rows ($Leads_H) in the table... without considering the ID of the chosen data.
It seems it doesn't recognize the ID of Q_ID
In my exemple:
<input type=hidden name=Q_ID[1] value=9>
<input type=hidden name=Q_ID[2] value=17>
it supposes to update Q_ID where the ID is 9 and 17...
Is anybody there who can help me please?
Everah | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]