Jump to content

Barand

Moderators
  • Posts

    24,563
  • Joined

  • Last visited

  • Days Won

    822

Everything posted by Barand

  1. You can just do this (if it is set then it must have been checked) $wallboxReqd = isset($_REQUEST['wallbox']) ? 1 : 0;
  2. Tinyint is fine. BTW, only checked checkbox values are posted.
  3. Give your checkboxes a name attribute ending with "[]" eg name=\"$item_no[]\" All selected values will then be posted in an array
  4. try outputting $roll instead of $roll1
  5. Did you change that line to use your own connection values? What error messages are you getting?
  6. PHP runs on the server. JS runs on the client once PHP has rendered the page.
  7. Make the id column auto_increment primary key. Make (date, route) a unique key.
  8. On reflection, change UNION above to UNION ALL UNION will suppress duplicates.
  9. If your printer can handle transparencies, can't you just print the page?
  10. If you are going to use print_r(), put it between <pre>..</pre> tags. It makes it so much more legible. echo '<pre>', print_r($myarray, true), '</pre>'; Or, better still, use var_export($myarray) then others can copy it straight into their editor.
  11. You can use the GD library to copy a load of smaller images into a larger image and then save the large image. If that is what you mean?
  12. You were clearing the $fdarray each time around the loop so you only finished up with the last one. I am now storing the $fdarray s into the $data array for processing. $oHTML = str_get_html($sHtml); $oTRs = $oHTML->find('table tr'); $data = array(); foreach($oTRs as $oTR) { $fdarray = array(); $oTDs = $oTR->find('td'); if ($oTDs) { foreach($oTDs as $oTD) { $fdarray[] = trim($oTD->plaintext); } $data[] = $fdarray; } } echo '<pre>',print_r($data, true),'</pre>'; echo "<hr>"; $new = array(); foreach ($data as $arr) { $key = join('|', array_slice($arr,0,3)); if (isset($new[$key])) { $new[$key][3][] = $arr[4]; } else { $new[$key] = array ($arr[0], $arr[1], $arr[2], array($arr[4])); } } foreach ($new as $arr) { echo "<hr>"; echo $arr[0]." --- ".$arr[1]." --- ".$arr[2]." --- ".join(', ', $arr[3])."<br>\n"; }
  13. try $db = new mysqli(HOST, USERNAME, PASSWORD, DATABASE ); $sql = "SHOW DATABASES"; $res = $db->query($sql); while (list($dbname) = $res->fetch_row()) { switch ($dbname) { case 'information_schema': case 'mysql': continue; default : $queries[] = "SELECT `NickName`,`FirstName`,`LastName`,`Email` FROM `$dbname`.`Profiles` \n"; break;; } } $sql = join(" UNION\n", $queries) . "ORDER BY Email"; echo '<pre>' . $sql . '</pre>'; // $sql IS THE QUERY TO BE EXECUTED You can check for duplicate emails as you process results
  14. Couple of other errors $pnd = "&pound"; - there should be a ; after pound $_REQUEST['answer'] = $answer; should be $answer = $_REQUEST['answer'];
  15. Output each card into a <div> with float:left style and desired width and height. Easier than table cells.
  16. try this $db = new mysqli(HOST, USERNAME, PASSWORD, 'elso' ); // // GET DISP_VALUES FOR HEADINGS // $sql = "SELECT DISTINCT disp_value FROM option_choices"; $res = $db->query($sql); $blank_discounts = array(); $output = "<tr><th>Product</th><th>Price</th>"; while ($row = $res->fetch_row()) { $output .= "<th>{$row[0]}</th>"; $blank_discounts[$row[0]] = 0; } $output .= "</tr>\n"; // // 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 product_name"; #echo query2HTMLtable($db, $sql); $res = $db->query($sql); while (list($prod, $price, $disp, $pc) = $res->fetch_row()) { if ($current_prod != $prod) { if ($current_prod) { $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 .= "<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> results attached
  17. Create a user_views table. When a user views a product, store id | user_id | product_id | timestamp That gives you ability to analyse by user, by product, by date and do things like "users who viewed that product also viewed ...."
  18. I agree with mac_gyver. Do not double post the same problem.
  19. Your original array had element [3] as the one that was to be grouped. You now say it is element [4]. Just change my code to use 4 instead of 3.
  20. WHERE date > curdate()-INTERVAL 7 day
  21. Perhaps you have some code that might help to make some sense of the question?
  22. What he actually said was you don't need the % at the beginning of those LIKE expressions ie LIKE '2013-05%'
  23. You aren't picking up the POSTed form data
  24. add ORDER BY category to the end of your current query see http://dev.mysql.com/doc/refman/5.6/en/select.html
×
×
  • 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.