Page 1 of 1

Array Hidden Variable Help

Posted: Tue Jun 21, 2005 10:12 am
by jbstone713
I have a form and I am trying to pass multiple values in an array to enter them into a database. However, sometimes when I can click submit it works, then other times i click submit, and the button does not work. Here is my code below. Any help would be greatly appreciated.

Code: Select all

<?php
require('db_connection.php');
session_start();
print ("<form name=info method=get action=handle_trade_estimates.php>");


if($trade == "carpentry"){
print ("<H3>Carpentry</H3>");
$sub_trade = array('carpentry', 'framing_material', 'truss_material', 'trim_material', 'stairs', 'framing_labor', 'trim_carpentry_labor');
}


////////////////Prints out everything that deals with sub_trades/////////////////////////////////////////

print ("<p>");
print ("<B>Please enter your bid amounts below.</B>");
print ("<BR>");
print ("<BR>");


for ($c = 0; $c < count($sub_trade); $c++){
$testy = each($sub_trade);

print ("<CENTER>");
print ("<TABLE border = 0 cellspacing = 0 cellpadding = 0>");
print ("<TR>");
print ("<TD align = center>");
print ("<p><B>Bids for $testy[value]</B>");
print ("</TR>");
print ("</TABLE>");

print ("<TABLE width = 75% border = 1 cellspacing = 0 cellpadding = 0>");
print ("<TR>");
print ("<TD align = center>");
print("<p>");
print ("<B>Company Name</B>");
print ("<TD align = center>");
print("<p>");
print ("<B>Bid Amount</B>");


//////////////////////////////////////////////////////////////////////////
//Sets the values from the company information = to a specified variable//
//////////////////////////////////////////////////////////////////////////

print ("<INPUT TYPE=hidden NAME=\"trade\" VALUE=\"$trade\">");
print ("<INPUT TYPE=hidden NAME=\"project\" VALUE=\"$project\">");

session_start();
$query_sub = "SELECT company_name, company_amount, company_sub_trade FROM estimates where project_id = ('$project') and company_sub_trade = ('$testy[value]')";
$result = mysql_query ($query_sub); 
while($row = mysql_fetch_array ($result)){
$name_sub = $row["company_name"];
$company_amount = $row["company_amount"];
$company_sub_trade = $row["company_sub_trade"];


print ("<TR>");
print ("<TD align = left>");
print("<p>");
print ("<INPUT TYPE=hidden NAME=\"name_sub[]\" VALUE=\"$name_sub\">");
print ("<INPUT TYPE=hidden NAME=\"new_sub_trade[]\" VALUE=\"$company_sub_trade\">");
//print ("<INPUT TYPE=hidden NAME=id[] VALUE=\"$company_name_id\">");
print ("&nbsp&nbsp$name_sub");
print ("<TD align = center>");
print ("<p>");
print ("<B>$</B><input name=\"amount[]\" value =\"$company_amount\" type=text size=2>");
}



print ("</TR>");
print ("</TABLE>");
print ("<BR>");
}


//////Ends the table and form////////
print ("</TR>");
print ("</TABLE>");
print ("<br>");
print ("<input type=submit name=next value=Next>");
print ("</form>");
print ("</CENTER>");
?>

Posted: Tue Jun 21, 2005 10:25 am
by phpScott
edit your post and use the php tags around it. the php button under the subject line
cheers.