Jump to content

Barand

Moderators
  • Posts

    24,584
  • Joined

  • Last visited

  • Days Won

    826

Everything posted by Barand

  1. 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
  2. what do your tables look like?
  3. Nothing changes! How are you doing?
  4. 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.
  5. There is an excellent class you can download called "AdLDAP". I used it all the time for AD applications
  6. That final ORDER BY should be GROUP BY. Guess you spotted that.
  7. 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
  8. 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;
  9. Your example used commas as separators in the CSV, you are now using semicolons.
  10. Did you allow for mine opening "input.txt" and writing to "output.txt"?
  11. 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])]; }
  12. 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);
  13. 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);
  14. Does mysql_error() say you have a syntax error?
  15. 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'
  16. Sphinx supports InnoDB
  17. 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
  18. WHERE name LIKE '%$word1%' AND name LIKE '%$word2%' AND name LIKE '%$word3%'
  19. Have a look at MySQL FULLTEXT searches
  20. If you want to constrain $maindamage to a minimum value of 10 $maindamage = max(10, ($rpgdata['max_dmg'] / $rpgdata['min_dmg']));
  21. Efficiency. One table subquery called once versus a dependent subquery called for every row
  22. if you leave it as a time field SELECT SEC_TO_TIME(AVG(TIME_TO_SEC(post_time_dif))) as tot FROM response WHERE profile_id = '$id' job done
  23. try a JOIN Select artist from songlist inner join (Select distinct title from songlist where artist='Bob Dylan') as dylan using (title)
  24. What format / column type is post_time_dif?
×
×
  • 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.