Page 1 of 1

Help with insert and select

Posted: Thu Aug 12, 2010 6:08 pm
by kingd3112
I am trying to do this add function. Where when you click the add link it saves a few fields of the product information(Set Database info) as well as the username and date(New Info).

This is what I have so far. The issue is that mysql_query posts two different rows in the table. I want it to just be one row. Any thoughts on how to link INSERT with a value and INSERT with SELECT.

Heres my code:
<? include("include/session.php"); ?>

<div id="popcontainer">
<div id="popupbox">
<div id="popdealbox">


<?
if ($a == add) {
$usel = mysql_query("select * from restaurant where id='$i'");
while ($upd = mysql_fetch_array($usel)) {
print "<br><br><br><br><br><center><h2> Would you like to add dash? <a href=add.php?a=adash&i=$upd[id]>Yes</a></h2></center>";
}

}


if ($a == adash) {
$userdining = $session->username;
$validfor = date("F j, Y");
mysql_query("INSERT INTO `mydash` (username, validfor) values ('$userding','$validfor')") or die("<center>Sorry Could Not Add Dash.</center>");
mysql_query("INSERT INTO `mydash` (name, linkpic) SELECT `name`, `linkpic` FROM `restaurant` where id='$i'") or die("<center>Sorry Could Not Add Dash.</center>");
print "<br><br><br><br><br><center><h2>Dash has been added!</h2> <a href=>View Deal</a></center>";
}

?>


</div>
</div>
</div>