Jump to content

Barand

Moderators
  • Posts

    24,584
  • Joined

  • Last visited

  • Days Won

    826

Everything posted by Barand

  1. Your data tables do not reflect that structure, it is more like country--+--> area | +--> region | +--> destination ----> rates <----- airline
  2. HTML syntax for a table is <table> <tr> <td> name1 </td> <td> qty1 </td> </tr> <tr> <td> name2 </td> <td> qty2 </td> </tr> </table> so put the data items inside <td>...</td> cells
  3. Now you have added the hidden field, $_POST['wallbox'] is always set, that's why it is always yes. You now need to check if it is equal to 1 instead of checking isset()
  4. You need to avaoid running queries inside loop as it kills performance. My version uses a single query to get all the required data. It stores the discount values in an array which output on change of product then cleared ready for the next set of product data. The keys of the array are the disp_values which are stored in a pre-created blank array. This the mysql version // // GET DISP_VALUES FOR HEADINGS // $sql = "SELECT DISTINCT disp_value FROM option_choices"; $res = mysql_query($sql); $blank_discounts = $vals = array(); $output = "<tr><th>Product</th><th>Price</th><th>"; while ($row = mysql_fetch_row($res)) { $vals[] = $row[0]; } // ensure values in correct order natsort($vals); $output .= join('</th><th>', $vals) . "</th></tr>\n"; $blank_discounts = array_fill_keys($vals,'0.000'); // // CREATE THE PRICING GRID // $current_prod = ''; $current_price = 0; $sql = "SELECT product_name, default_price, disp_value, percentage FROM product INNER JOIN product_options USING (product_ID) INNER JOIN option_choices USING (option_number) ORDER BY default_price"; $res = mysql_query($sql); while (list($prod, $price, $disp, $pc) = mysql_fetch_row($res)) { if ($current_prod != $prod) { if ($current_prod) { // on change of product output array of discounts $output .= "<tr><td>$current_prod</td><td>$current_price</td>"; foreach ($prod_discounts as $disc) { $output .= "<td>$disc</td>"; } $output .= "</tr>\n"; } $current_prod = $prod; $current_price = $price; $prod_discounts = $blank_discounts; } $prod_discounts[$disp] = number_format($pc,3); } // output array of dicounts for final product $output .= "<tr><td>$current_prod</td><td>$current_price</td>"; foreach ($prod_discounts as $disc) { $output .= "<td>$disc</td>"; } $output .= "</tr>\n"; ?> <table border="1" cellpadding="4"> <?php echo $output ?> </table>
  5. Set the value before outputting the table $isWallboxPatchReqd = isset($_REQUEST['wallbox']) ? 'yes' : 'no'; .... echo "<td>$isWallboxPatchReqd</td>"; ....
  6. String values in a query need to be quoted thus '$isWallboxPatchReqd', otherwise sql assumes they are column names
  7. I showed you how in your similar post yesterday http://forums.phpfreaks.com/topic/279073-checkbox-values/?do=findComment&comment=1435557
  8. If you want the field to remain null when it is blank exclude it from the update so you do not provide a value.
  9. dates('s') has a value range of 0 - 59. It is the seconds element of the time display.
  10. What is in $_FILES['file']['type'] ? What does $_FILES['file']['tmp'] contain?
  11. It reads that as ziguana_cystic minus fibrosis.Profiles. Use backticks (or don't use hyphens) `ziguana_cystic-fibrosis`.Profiles
  12. You only need call the function for displayed comments - You aren't planning on displaying 50.000 at a time, are you?
  13. I suspect you data model isn't fully normalized Winery (pid) 2 is always in region 4 so you don't need pid and rid in the product table. location | +-------< region | +-----------< winery varietal | | +-------< product >----------+
  14. Use DateTime and DateInterval objects. $timestamp = '2013-06-13 01:00:00'; $dt = new DateTime($timestamp); $diff = $dt->diff(new DateTime())->format('%y,%m,%d,%h,%i,%s'); list ($y, $m, $d, $h, $n, $s) = explode(',', $diff); edit: result $diff = 0,0,0,0,39,5
  15. For your first requirement you need to construct a query with this WHERE clause WHERE (col LIKE '%d%') OR (col LIKE '%r%') OR (col LIKE '%e%') OR (col LIKE '%a%') For the second, replace the OR with AND
  16. Give us a clue. How do you want it to appear?
  17. After running the query, what does mysql_error() tell you?
  18. First you complain about duplicates then you say they can be duplicated. I'm out of here.
  19. or SELECT gender, COUNT(*) as total FROM dmc_stats JOIN ReportRange ON encdate BETWEEN bdate AND edate WHERE cf_id = 1 GROUP BY gender;
  20. If I were you I'd stick with a tinyint with values 0 or 1. However, if you want 'Yes' or 'No' (which then gives complications of testing for ' yes' or 'Yes' ) then $wallboxReqd = isset($_REQUEST['wallbox']) ? 'yes' : 'no'; and you will need to change the field type in the db table
  21. Sorry, I just copied your name= bit and didn't spot the $ in the name. Try echo "<input type=\"checkbox\" name=\"item_no[]\" value=\"$item_no\" />$item_no $ihddescr_1<br />"; Your selected item numbers will be in the array $_POST['item_no']
  22. You can just do this (if it is set then it must have been checked) $wallboxReqd = isset($_REQUEST['wallbox']) ? 1 : 0;
  23. Tinyint is fine. BTW, only checked checkbox values are posted.
  24. Give your checkboxes a name attribute ending with "[]" eg name=\"$item_no[]\" All selected values will then be posted in an array
  25. try outputting $roll instead of $roll1
×
×
  • 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.