0

Im struggling with updating the sql database for all fields . For example i have 2 select boxes in my order and if i wanted to amend both of them i change there details and press submit. The problem is i dont know how to loop it to go to the 2nd select box. The example below only does the first one in the list. i have tried various loops but with fail. thats why i went back to just trying to get one to change.

any help in the right direction would be great.

kard

<?
require "backend/functionsemail.php";
#require  "backend/order.php";
dbconn();

$res90 = mysql_query("SELECT * FROM eventcustomers left join eventcompany on eventcompany.compid = eventcustomers.compid left join constructionorderdetails on constructionorderdetails.conorderid = eventcustomers.compid left join products on products.productid = constructionorderdetails.productid WHERE eventcustomers.compid = '36'") or die;

$sql = "SELECT * FROM products ORDER BY productid";
$result = mysql_query($sql);

stdhead("Home");

begin_frame ("test3");
$num=0;
?>
<form name="amendorder" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data">
<?

while($row = mysql_fetch_array($res90))
{ 
if ($row[conorderid] == '36'){
	print "$row[orderid]";
print "$row[productid]";
print"<input type=hidden name=orderid value=$row[orderid]>";
print "<select name=\"prodid\">";
   
      while($row1 = mysql_fetch_array($result))
      {
     $sel = ($row1['productid'] == $row['productid']) ? "selected=\"selected\"" : "";
         printf("<option value=\"%s\" %s>%s</option>\n", $row1['productid'], $sel, $row1['product']);
       }
#while($row1 = mysql_fetch_array($result))
#{<option value=\"%s\" %s>%s</option
#echo "<option value=\"".$row1['product']."\">      ".$row1['product']."</option> \n ";

#}
echo "</select>";
mysql_data_seek($result,0);
print "$num";

#print"<input style=\"text-align:center\" type=text name=ctweeks value=\"$row[productitems]\"  size=10>";
#print"<input style=\"text-align:center\" type=text name=ctweeks value=\"$row[productcost]\"  size=10>";

print "<br>";
$num++;
}else{
	print " no records";
}}


?>
<input type="submit" name="submit" value="submit" />
</form>
<?


end_frame();


    if(isset($_POST['submit']))
##This checks to make sure submit was clicked
    {
        echo "You clicked submit!<br>";
        echo "Here is your data<br>";
        echo "<br>";
   #     if ($_POST['productitems_0'])
##This checks that the proper field has data
    #    {
             #   $continue = FALSE;
             #   $i = 0;
                $compid = $_POST['prodid'];
                $orderid = $_POST['orderid'];
             #   while ($continue == FALSE)
             #   {
             #       if (isset($_POST['prodid_'.$i]))
#This looks for an entry after 0 and increments
                 #   {
                  #  echo $_POST['prodid_'.$i] . " = " . $_POST['productitems_'.$i] . " = " . $_POST['productcost_'.$i] . "<br>";
#Echoing the data
print" $compid <br>";
mysql_query("UPDATE constructionorderdetails SET productid = $compid WHERE orderid = $orderid ");
                #}
                #else
                #{
                 #   $continue = TRUE;
                #}
                #$i++;
    print " end ";
    
            #}
        }
  #  }






stdfoot();



?>
1
Contributor
1
Reply
2
Views
6 Years
Discussion Span
Last Post by kardklub
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.