-
Posts
24,563 -
Joined
-
Last visited
-
Days Won
822
Everything posted by Barand
-
perhaps @VAL := LAST_INSERT_ID(); INSERT INTO `otherTb` (user_id, `instance_id`, `category_id`,) VALUES (@VAL, NULL, 04);
-
which of those 2 tables, votes or user_votes, does NOT have a poll_id until the user votes?
- 19 replies
-
- not exists
- rand()
-
(and 1 more)
Tagged with:
-
All 3 of them
- 19 replies
-
- not exists
- rand()
-
(and 1 more)
Tagged with:
-
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
- 19 replies
-
- not exists
- rand()
-
(and 1 more)
Tagged with:
-
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
- 19 replies
-
- not exists
- rand()
-
(and 1 more)
Tagged with:
-
what do your tables look like?
- 19 replies
-
- not exists
- rand()
-
(and 1 more)
Tagged with:
-
Nothing changes! How are you doing?
-
my code for save mobile number doesn't work correctly
Barand replied to nekooee's topic in PHP Coding Help
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. -
There is an excellent class you can download called "AdLDAP". I used it all the time for AD applications
-
That final ORDER BY should be GROUP BY. Guess you spotted that.
-
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
-
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;
-
Find and delete duplicates under the right condition
Barand replied to PatrickPetersen's topic in PHP Coding Help
Your example used commas as separators in the CSV, you are now using semicolons.- 19 replies
-
- csv
- dublicates
-
(and 3 more)
Tagged with:
-
Find and delete duplicates under the right condition
Barand replied to PatrickPetersen's topic in PHP Coding Help
Did you allow for mine opening "input.txt" and writing to "output.txt"?- 19 replies
-
- csv
- dublicates
-
(and 3 more)
Tagged with:
-
Find and delete duplicates under the right condition
Barand replied to PatrickPetersen's topic in PHP Coding Help
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])]; }- 19 replies
-
- csv
- dublicates
-
(and 3 more)
Tagged with:
-
Find and delete duplicates under the right condition
Barand replied to PatrickPetersen's topic in PHP Coding Help
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);- 19 replies
-
- csv
- dublicates
-
(and 3 more)
Tagged with:
-
my code for save mobile number doesn't work correctly
Barand replied to nekooee's topic in PHP Coding Help
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); -
Does mysql_error() say you have a syntax error?
-
query string to variable to ini then imagettftext
Barand replied to l3l00's topic in PHP Coding Help
Interesting. -
Find and delete duplicates under the right condition
Barand replied to PatrickPetersen's topic in PHP Coding Help
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'- 19 replies
-
- csv
- dublicates
-
(and 3 more)
Tagged with:
-
Sphinx supports InnoDB
-
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
-
WHERE name LIKE '%$word1%' AND name LIKE '%$word2%' AND name LIKE '%$word3%'
-
Have a look at MySQL FULLTEXT searches
-
Need to get the "ABOVE AVERAGE" value, not the divided by one.
Barand replied to Monkuar's topic in PHP Coding Help
If you want to constrain $maindamage to a minimum value of 10 $maindamage = max(10, ($rpgdata['max_dmg'] / $rpgdata['min_dmg']));