Jump to content

Barand

Moderators
  • Posts

    24,563
  • Joined

  • Last visited

  • Days Won

    822

Everything posted by Barand

  1. perhaps @VAL := LAST_INSERT_ID(); INSERT INTO `otherTb` (user_id, `instance_id`, `category_id`,) VALUES (@VAL, NULL, 04);
  2. which of those 2 tables, votes or user_votes, does NOT have a poll_id until the user votes?
  3. All 3 of them
  4. 1 You need all the items being voted on so you know which are missing 2. You need all users so you know who has not voted 3. You need which user voted for which item
  5. To do this you need 3 tables voter : voterid | voter item : itemid | item votes : itemid | voterid Create a cartesian join between voter and item to get all combinations then left join with votes to see which combinations are missing
  6. what do your tables look like?
  7. Nothing changes! How are you doing?
  8. As I said, it worked fine for me, but then I was using my own test data files. Attach your data files and I see if it makes a difference.
  9. There is an excellent class you can download called "AdLDAP". I used it all the time for AD applications
  10. That final ORDER BY should be GROUP BY. Guess you spotted that.
  11. try SELECT date, aname, SUM(total_leads) as total FROM ( SELECT DATE(l.time1) as date,a.affid,a.aname, COUNT(l.reqid) as total_leads FROM leads l LEFT JOIN affiliates AS a ON l.affid = a.affid LEFT JOIN campaign AS c ON l.campid = c.campid WHERE (a.affid = l.affid) GROUP BY DATE(l.time1),a.aname UNION ALL SELECT DATE(x.extstamp) as date,a.affid,a.aname, COUNT(x.reqid) as total_leads FROM ext_leads x LEFT JOIN clicks AS cl ON cl.reqid = x.reqid LEFT JOIN affiliates AS a ON a.affid = cl.affid_sid WHERE (cl.reqid = x.reqid) GROUP BY DATE(x.extstamp),a.aname ) as sub ORDER BY date, aname
  12. try $db = mysqli_connect(HOST, USERNAME, PASSWORD, DATABASE); // connect to database $costSql = 'SELECT sum(amount) FROM costs'; // define the query $result = mysqli_query($db, $costSql); // execute the query $row = mysqli_fetch_row($result); // get return row $costs = $row[0]; // get the total $donationsSql = 'SELECT sum(amount) FROM donations'; // define the query $result = mysqli_query($db, $donationsSql); // execute the query $row = mysqli_fetch_row($result); // get return row $donations = $row[0]; // get the total $result = $donations - $costs;
  13. Your example used commas as separators in the CSV, you are now using semicolons.
  14. Did you allow for mine opening "input.txt" and writing to "output.txt"?
  15. Needs a little adjustment to sort the data by rank for each street $fp = fopen('input.txt', 'r'); $data = array(); $head = fgetcsv($fp, 1024); // header line while ($line = fgetcsv($fp, 1024)) { $data[$line[0]][] = $line; } fclose($fp); // // write to file // $fp = fopen('output.txt', 'w'); fputcsv($fp, $head); foreach ($data as $street=>$streetdata) { // use a custom sort to sort by ranking usort($streetdata, 'sortrank'); // we only want the one with the highest ranking $line = array_shift($streetdata); fputcsv($fp, $line); } fclose($fp); function sortrank($a, $b) { $rank = array ( 'Ready' => 1, 'Possible' => 2, 'BBU - Possible' => 3, 'Pipe ready' => 4, 'BBU - Pipe ready' => 5, 'Established' => 6, 'Waiting for planning' => 7, 'Study' => 8, 'Not possible/Project delayed' => 9, 'Not possible' => 10, 'Not relevant' => 11, 'Unknown' => 12, 'BBU - Unknown' => 13 ); return $rank[trim($a[1])] - $rank[trim($b[1])]; }
  16. Hope this makes amends (at least you've seen the benefit of a database) $fp = fopen('input.txt', 'r'); $data = array(); $head = fgetcsv($fp, 1024); // header line while ($line = fgetcsv($fp, 1024)) { $data[$line[0]][] = $line; } fclose($fp); // // write to file // $fp = fopen('output.txt', 'w'); fputcsv($fp, $head); foreach ($data as $street=>$streetdata) { $dupe = count($streetdata) > 1; foreach ($streetdata as $line) { if ($dupe && trim($line[1])=='Unknown') { continue; } else { fputcsv($fp, $line); } } } fclose($fp);
  17. I was unable to re-create the error. It all seems to work fine for me. The only problem I can see is you are outputting an unnecessary linefeed at the end. echo '<center dir="ltr">'.$Number.' new number saved</center>'; fwrite($file_D,"\n"); // <-------- not required fclose($file_S); fclose($file_D);
  18. Does mysql_error() say you have a syntax error?
  19. Backup your data first DELETE profile FROM profile JOIN ( SELECT street FROM profile GROUP BY street HAVING COUNT(*) > 1 ) as dupes USING (street) WHERE status = 'Unknown'
  20. Sphinx supports InnoDB
  21. Even though you are not calling mysql_close() the connection will close automatically at end of each page script. Connect once at beginning of each page that requires mysql
  22. WHERE name LIKE '%$word1%' AND name LIKE '%$word2%' AND name LIKE '%$word3%'
  23. Have a look at MySQL FULLTEXT searches
  24. If you want to constrain $maindamage to a minimum value of 10 $maindamage = max(10, ($rpgdata['max_dmg'] / $rpgdata['min_dmg']));
×
×
  • 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.