Jump to content

Barand

Moderators
  • Posts

    24,563
  • Joined

  • Last visited

  • Days Won

    822

Everything posted by Barand

  1. How are you getting the list of ids for selection in the first instance?
  2. It seems like you need to to learn the basics of HTML before you embark on PHP to produce web pages
  3. Post your code. Use the <> button above.
  4. echo mysql_error() after code to see if an error occurred
  5. try $favourites = array(); $fh = fopen('test.txt', 'r'); $line = fgetcsv($fh, 1024); // header while ($line = fgetcsv($fh, 1024)) { $data = $line[9]; $favourites = array_merge($favourites, explode('|', $data)); } $favourites = array_map('trim', $favourites); $counts = array_count_values($favourites); arsort($counts);
  6. use a subquery eg SELECT invoiceId FROM ( SELECT invoiceId FROM invoices ORDER BY invoiceID DESC LIMIT 10 ) as lastten ORDER BY invoiceId ASC;
  7. Was it too difficult to paste a couple of sample lines, or to punctuate that reply to show birth and date are one field (I assume anyway)? If you can't be bothered to give better information, why should I?
  8. What does data.csv look like?
  9. try $data = file('test.txt'); $teams = array(); foreach ($data as $line) { $teams = array_merge($teams, explode('|', $line)); } $teams = array_map('trim', $teams); $counts = array_count_values($teams); arsort($counts);
  10. You should read the manual re mysql_fetch_row or mysql_fetch_assoc
  11. gingerjm, you really should take your own advice
  12. With that csv file list($state, $balance) = $data; will put Account and State into $state and $balance. try list(,$state,,,,,$balance) = $data;
  13. It doesn't matter if you use $row, $row1 or $slartybartfast. Just be consistent. You can't use use $row for some fields and $row1 for others in the same while loop.
  14. Is it because you are using $row1 in the loop?
  15. A. What format are those columns? B. What have you tried?
  16. Prior to 5.4 it works only if short php tags are enabled. From 5.4 it works regardless of the short tag setting
  17. 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
  18. No. If you want it sorted by id use ... ORDER BY id
  19. 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); } }
  20. 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.
  21. 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
  22. 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)
  23. EG item | cat ----------- 1 | 10 1 | 11 1 | 12 2 | 1 3 | 2 3 | 10 3 | 12
×
×
  • 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.