Reputation: 1055
I am having trouble creating option and posting them along with the form its a part of.
Here's what I currently have. The db connector is already working.
<select class="form-dropdown validate[required]" style="width:150px" id="input_5" name="account">
<?php
while($row = mysql_fetch_row($result)){
$bid =$row[0];
$account = $row[1];
echo '<option value="'.$bid.'>"'.$account.'"</option>"';
}
?>
</select>
It will not post to:
function calculateBilling(){
$date = date('mdY');
$bid = mysql_real_escape_string($_POST['bid']);
$account = mysql_real_escape_string($_POST['account']);
$timein = mysql_real_escape_string($_POST['timein']);
$desc = mysql_real_escape_string($_POST['desc']);
$hrs2calc1 = mysql_real_escape_string($_POST['hrly']);
$hrs2calc2 = mysql_real_escape_string($_POST['rhrly']);
$query = 'SELECT bid, account, hrly, rhrly, bal FROM billing WHERE bid="'.$bid.'"';
echo $query;
$result = mysql_query($query);
while($row = mysql_fetch_row($result)){
$accounttobebilled = $row[1];
$first = $row[2];
$second = $row[3];
$curbal = $row[4];
}
$sub1 = $hrly * $hrs2calc1;
$sub2 = $rhrly * $hrs2calc2;
$subtotal = $sub1 + $sub2;
$total = $curbal + $subtotal;
mysql_query("UPDATE billing SET bal = '" . $total . "' WHERE bid ='" . $bid . "'");
// Update Billing Log for this customer
mysql_query("INSERT INTO billingLog (bid, date, hrsOnsite, hrsRemote, timein, descript, total) VALUES ('$bid', '$date', '$hrs2calc1', '$hrs2calc2', '$timein', '$desc', '$subtotal')");
}
My problem is the billing id (bid) is not posting along with the form it is wrapped in. If I echo $bid on the html page before I post it, it pulls fine. It just doesn't post to the function above. bid is an integer.
Thanks!!
Upvotes: 0
Views: 510
Reputation: 77996
Your quotes are wacky:
echo '<option value="'.$bid.'>"'.$account.'"</option>"';
would output: <option value="123>"My Account Name"</option>"
Try this:
echo '<option value="'.$bid.'">'.$account.'</option>';
That should output: <option value="123">My Account Name</option>
Upvotes: 1