Jump to content

Barand

Moderators
  • Posts

    24,602
  • Joined

  • Last visited

  • Days Won

    830

Everything posted by Barand

  1. A. What format are those columns? B. What have you tried?
  2. Prior to 5.4 it works only if short php tags are enabled. From 5.4 it works regardless of the short tag setting
  3. Use a table JOIN SELECT p.prod_name, p.prod_photo, pr.prod_price FROM tblproduct p INNER JOIN tblretprod pr ON p.prod_id = pr.prod_id ORDER BY RAND() LIMIT 6
  4. No. If you want it sorted by id use ... ORDER BY id
  5. my preferred method Code tags appear to be FUBAR so here it is without them $db = new mysqli(HOST, USERNAME, PASSWORD, DATABASE ); $sql = "SELECT pat_id as `Patient ID` ,pat_lname as `Patient Last Name` ,pat_fname as `Patient First Name` ,pat_date as `Date` ,office_name as `Patient Location` ,pat_ins ,pat_show FROM patients INNER JOIN offices ON office_id = pat_loc INNER JOIN insurance ON ins_id = pat_ins "; sql2csv($db, $sql, 'mydata.csv', 1); // // function to download csv // function sql2csv($mysqli, $sql, $filename='', $headings=1) { if (!$filename) $f = 'download_' . date('ymdhi') . '.csv'; else $f = $filename; if ($fp) { $res = $mysqli->query($sql); if ($res) { header('Content-Type: text/csv'); header('Content-Disposition: attachment; filename="'.$f.'"'); header('Pragma: no-cache'); header('Expires: 0'); $row = $res->fetch_assoc(); if ($headings) { fputcsv($fp, array_keys($row)); } do { fputcsv($fp, $row); } while ($row = $res->fetch_assoc()); } else echo "Error in query"; fclose($fp); } }
  6. When you get to the answer page, $_POST['ans1'] no longer exists so you are clearing the session value. You need to store $_POST['ans11'] on that page.
  7. UPDATE table1 INNER JOIN table2 USING (id) SET table2.date = table1.date Also change your date fields to type DATE, format YYYY-MM-DD. Your format is useless in a database
  8. Store them as DATE, DATETIME or TIMESTAMP types. Formats are YYYY-MM-DD HH:ii:ss for datetime and timestamp and YYYY-MM-DD for date type Using these types will give maximum functionality (usable by the date/time functions in MySql and can be easily sorted/compared)
  9. EG item | cat ----------- 1 | 10 1 | 11 1 | 12 2 | 1 3 | 2 3 | 10 3 | 12
  10. The correct way is <input type="radio" name="serial_number" value="<?php echo $serial_number ?>" /> If the radio has a variable name you have no idea which POST variable to process - it could be called anything.
  11. I'd make a couple of changes to that query. In the subquery, have IFNULL(MAX(m.date_posted), '0000-00-00') as lastPost and then order the whole query by ORDER BY MAX(t.date_posted, q.lastPost) so it sorts by the lastest message (if exist) or the thread date, whichever is latest
  12. Have you checked that the $info array contains what you expect?
  13. You create an intermediate table containing item_id | category_id one row for each cat/subcat the item belongs to
  14. :code_php_tags:
  15. you have no ; at the end of the statement on previous line
  16. In my code, $currOrg gets set on the line after the part you just posted. That code was tested prior to posting. output was Organisation: organization_w Email: email_w Titles: publication_w1, publication_w2, publication_w3 Ids: pubID_w1, pubID_w2, pubID_w3 -------------------------------------------------------------------------------- Organisation: organization_x Email: email_x Titles: publication_x1, publication_x2, publication_x3 Ids: pubID_x1, pubID_x2, pubID_x3 -------------------------------------------------------------------------------- Organisation: organization_y Email: email_y Titles: publication_y1, publication_y2 Ids: pubID_y1, pubID_y2 -------------------------------------------------------------------------------- Organisation: organization_z Email: email_z Titles: publication_z Ids: pubID_z
  17. Turn PHP error reporting on. You should be getting a syntax error with that code
  18. You don't need, and shouldn't, reconnect before each query. It's usually the slowest part of the process. You only to connect once per page. I'd connect to the database then pass $db to the class constructor. Inside the function you then reference $this->db class foo { private $db; function __construct($db) { $this->db = $db; } function bar() { $result = $this->db->query("SELECT blah from table"); .... return $blah; } } $db = new mysqli(......); $obj = new foo($db)
  19. Don't you already have that in your retailer table (id, user_id, prod_id)?
  20. try $arr = array ( array('org' => organization_w, 'email' => email_w, 'title' => publication_w1, 'pub_id' => pubID_w1), array('org' => organization_w, 'email' => email_w, 'title' => publication_w2, 'pub_id' => pubID_w2), array('org' => organization_w, 'email' => email_w, 'title' => publication_w3, 'pub_id' => pubID_w3), array('org' => organization_x, 'email' => email_x, 'title' => publication_x1, 'pub_id' => pubID_x1), array('org' => organization_x, 'email' => email_x, 'title' => publication_x2, 'pub_id' => pubID_x2), array('org' => organization_x, 'email' => email_x, 'title' => publication_x3, 'pub_id' => pubID_x3), array('org' => organization_y, 'email' => email_y, 'title' => publication_y1, 'pub_id' => pubID_y1), array('org' => organization_y, 'email' => email_y, 'title' => publication_y2, 'pub_id' => pubID_y2), array('org' => organization_z, 'email' => email_z, 'title' => publication_z, 'pub_id' => pubID_z) ); $currOrg = ''; foreach ($arr as $data) { if ($currOrg != $data['org']) { if ($currOrg) { outputEmail ($currOrg, $currEmail, $titles, $ids); } $currOrg = $data['org']; $currEmail = $data['email']; $titles = $ids = array(); } $titles[] = $data['title']; $ids[] = $data['pub_id']; } outputEmail ($currOrg, $currEmail, $titles, $ids); function outputEmail($org, $email, $titles, $ids) { // format your output here echo "Organisation: $org<br>"; echo "Email: $email<br>"; echo "Titles: " . join(', ', $titles) . '<br>'; echo "Ids: " . join(', ', $ids) . '<hr>'; }
  21. Use the rows' primary keys to identify which x should get which value
  22. line 118 is missing ; at end of statement and you are using the wrong variable on line 121 $objResult = mysql_fetch_array($objQuery); $provinceFullName = $objResult["province_english"];
  23. I can understand that retailers would have different prices but why would descriptions of the same product be different for each retailer? More likely the model would be more like this +------------+ +--------------+ | retailer | | product | +------------+ +--------------+ | user_id |----+ +------------------+ +-----| product_id | | user_name | | | retailer_product | | | prod_name | | etc | | +------------------+ | | prod_desc | +------------+ +---<| user_id | | | manufacturer | | product_id |>---+ | product_code | | price | | etc | +------------------+ +--------------+
×
×
  • 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.