0

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!!

1
  • Can you provide the outputted HTML? Commented Jul 29, 2011 at 23:08

2 Answers 2

1

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>

Sign up to request clarification or add additional context in comments.

4 Comments

I always screw those up.. It won't post to my php.. Look above!! thank you
Trust me :) Based on your code, this is why it's not working.
No.. It's not posting to the function above. I fixed the quotes though.
The only thing I see based off of your updated code is that you're running your SQL query looking at $bid when the <select name="account"> and should probably be <select name="bid">
0

My name on the item wasn't bid. Fixed!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.