Jump to content

thirdphase

New Members
  • Posts

    5
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

thirdphase's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I have created a basic array by pulling values from a database but now need to count how many of the array values are 0. Here is my code so far: $qty_array = array(); $qty_array[0] = $product_row["WF_qty"]; $qty_array[1] = $product_row["SD_qty"]; $qty_array[2] = $product_row["DD_qty"]; $qty_array[3] = $product_row["CD_qty"]; $qty_array[4] = $product_row["PD_qty"]; $qty_array[5] = $product_row["SP_qty"]; $qty_array[6] = $product_row["VS_qty"]; $qty_array[7] = $product_row["RO_qty"]; $qty_array[8] = $product_row["PO_qty"]; $qty_count = count($qty_array); This is returning the value 9 as I expected but I am not sure how to change the count function so that I count values that are 0 and ignore the rest. Can anyone help?
  2. I have now moved all of the php code above the html and it works fine! Obvious when you know how! Thanks for your help
  3. Thanks for your reply. I thought that was the case but I'm not sure how else I can do this, as I can't put all of the code to send the data to the database above the setcookie as this doesn't work either! The 5 seconds was set so that the cookie would only exist long enough to redirect back to the form page and populate the fields again. Would there be another way of sending this variable??
  4. I am trying to pass a variable as a cookie from one page to another, but can't seem to get it working. The first page has a form with a submit button. The forms action goes to a second page called updated.php. In the updated.php page I have the following code (with the cookie right at the top before anything else): <?php setcookie("get_orderID", $get_orderID, time()+5); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> etc... Later in this page I have the code to send the original form data to an sql database and then retireve an auto increment value back from the database as follows: <?php if($edit_orderID == 0) { $submit_order_sql = "insert into my_orders (date, name, clientID) values ( \"$date\", \"$name\", \"$clientID\" )"; $submit_order_rs = mysql_query( $submit_order_sql, $conn ); $get_order_sql="select orderID from my_orders where job_no = $job_no"; $get_order_rs = mysql_query( $get_order_sql,$conn ); $get_order_row = mysql_fetch_array( $get_order_rs ); $get_orderID = $get_order_row["orderID"]; ?> Finally I need to send the variable I have found back to the form page (using a cookie). But it seems that as the variable is being created at the bottom of the page, the cookie at the top is not seeing the variable. Can anyone help please?? Thanks.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.