Jump to content

Barand

Moderators
  • Posts

    24,584
  • Joined

  • Last visited

  • Days Won

    826

Everything posted by Barand

  1. Did you change that line to use your own connection values? What error messages are you getting?
  2. PHP runs on the server. JS runs on the client once PHP has rendered the page.
  3. Make the id column auto_increment primary key. Make (date, route) a unique key.
  4. On reflection, change UNION above to UNION ALL UNION will suppress duplicates.
  5. If your printer can handle transparencies, can't you just print the page?
  6. 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.
  7. 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?
  8. 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"; }
  9. 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
  10. Couple of other errors $pnd = "&pound"; - there should be a ; after pound $_REQUEST['answer'] = $answer; should be $answer = $_REQUEST['answer'];
  11. Output each card into a <div> with float:left style and desired width and height. Easier than table cells.
  12. 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
  13. 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 ...."
  14. I agree with mac_gyver. Do not double post the same problem.
  15. 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.
  16. WHERE date > curdate()-INTERVAL 7 day
  17. Perhaps you have some code that might help to make some sense of the question?
  18. What he actually said was you don't need the % at the beginning of those LIKE expressions ie LIKE '2013-05%'
  19. You aren't picking up the POSTed form data
  20. add ORDER BY category to the end of your current query see http://dev.mysql.com/doc/refman/5.6/en/select.html
  21. "WHERE" selection conditions on a left-joined table need to be part of the join. Try SELECT v.* FROM votes v LEFT JOIN user_votes uv ON v.poll_id = uv.vote_poll_id AND uv.voter_id = $id WHERE v.user_id != $id AND uv.vote_poll_id IS NULL ORDER BY RAND() LIMIT 1
  22. Just as you would in C echo '<pre>'; for ($i=0, $k=count($fileinfo); $i < $k; $i++) { printf ("%3d\t%8d\t%-15s\n", $i, $fileinfo[$i][0], $fileinfo[$i][1]); } echo'</pre>';
  23. Most common storage format is "YYYY-MM-DD HH:NN:SS"
  24. Don't store your dates as unix timestamps - store them as type DATETIME, format "yyyy-mm-dd hh:ii:ss"
×
×
  • 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.