Jump to content

Barand

Moderators
  • Posts

    24,602
  • Joined

  • Last visited

  • Days Won

    830

Everything posted by Barand

  1. You could put the condition in the query EG SELECT (CASE Post_Id WHEN 7 THEN 0.00 ELSE Post_cost END) as Post_cost, ...
  2. Strange how it "worked" in PhpMyAdmin then
  3. show the data echo '<pre>', print_r($fbdata->data, 1), '</pre>';
  4. Store in array then join(). $f_pointer=fopen("unique.csv","r"); // file pointer $users = array(); while ($ar=fgetcsv($f_pointer)) { $users[] = $ar[0]; } fclose ($f_pointer); $list = join(',', $users);
  5. Case sensitivity!. $Ctry = $WV_info['country']; should be $Ctry = $WV_info['Country']; Are you really storing data in a separate table for each week?
  6. Use "\n" and not "<br>" in textareas. <?php $txt = ''; while($stmt->fetch()){ $txt .= $date . " " . $stratoparse . "\n\n"; } ?> <textarea cols="50" rows="10"> <?php echo $txt; ?> </textarea>
  7. How can we figure it out when you give us little more than "it doesn't work"? Have you tried outputting the content from mysqli_error() after attempting the insert query? What is the output from "echo $sql;" ? We are not looking over your shoulder seeing what you see on the screen. I doubt anyone here is going to download the content of an unknown file. If you got an email saying you had won 1 million dollars and had to click on a download link for details, would you? Post the output from "SHOW CREATE TABLE products".
  8. Does this mean you have given up trying to find the reason for the error (even though you've been told how) and want us to do the work for you?
  9. While developing, instead of just outputting "errror", try outputting something helpful to you, like mysqli_error
  10. this will do it $a['a'] = array('a' => '5'); $a['b'] = array('b' => '4'); $a['c'] = array('c' => '3'); $a['d'] = array('z' => '2'); $a['e'] = array('f' => '1'); echo '<pre>'; uasort($a, 'mysortASC'); print_r($a); uasort($a, 'mysortDESC'); print_r($a); echo '</pre>'; function mysortASC($a, $b) { $atmp = array_values($a); $btmp = array_values($b); return $atmp[0] - $btmp[0]; } function mysortDESC($a, $b) { $atmp = array_values($a); $btmp = array_values($b); return $btmp[0] - $atmp[0]; }
  11. It would work for indexed arrays (they will sort on the value of the first item) but not for associative arrays like that one. It does work if the associative arrays have consistent key values for comparisonEG $a['a'] = array('a' => '5'); $a['b'] = array('a' => '4'); $a['c'] = array('a' => '3'); $a['d'] = array('a' => '2'); $a['e'] = array('a' => '1'); That lack of consistency of array keys also make the custom sort option problematical too.
  12. Just in case you aren't using a database, you can sort the array by good(DESC), time(ASC) then take the the first element. $results = [ ['name'=>'carl', 'good'=>1, 'time'=>14], ['name'=>'john', 'good'=>2, 'time'=>25], ['name'=>'benny', 'good'=>2, 'time'=>21] ]; usort($results, 'resultSort'); echo $results[0]['name']; // benny function resultSort($a, $b) { // compare by 'good' DESC $x = $b['good'] - $a['good']; if ($x==0) { // if same, compare by 'time' ASC return $a['time'] - $b['time']; } else return $x; }
  13. http://php.net/manual/en/function.mail.php see example #2
  14. If the user chooses the "All" option then you can leave that column and the condition value out of the query
  15. You can't bind column names, only values $pp1 = 'Beginner'; $pp2 = 'Intermediate'; $ll = 7; $room_no = 4; $query = "SELECT md.Member_reg_id, md.fname, md.lname, md.email, md.cell, ms.level, ms.diff, ms.score, r.ID_Status FROM register as r JOIN member_detail as md ON r.ID = md.Member_reg_id JOIN memstatus as ms On r.ID = ms.ID WHERE r.CENTERCODE = ? AND r.ID_Status ='A' AND ms.level IN (?,?) AND ms.diff <= ? ORDER by level, diff, score DESC"; $stmt=$fcon->prepare($query); $stmt->bind_param('issi',$room_no,$pp1,$pp2,$ll);
  16. The string that you are echoing finishes at the ' after location.href= You need to escape the single quotes within the string echo'<input name="Enabled" type="button" value="Enabled" onclick="location.href=\'../edit.php\'"/>';
  17. One connection will suffice, and when you decide on MySQLi or PDO, use a prepared query. And you do not specify which column the value $killforumid should be written to
  18. Of the two I think confusion is the more likely option. You brilliant coding merely takes an array that looks like this $row = array( array('CID'=>100,'Country'=>'France'), array('CID'=>200,'Country'=>'Germany'), array('CID'=>300,'Country'=>'Holland') ); and converts it to an array that looks like this $countries = array( array('0'=>100,'1'=>'France'), array('0'=>200,'1'=>'Germany'), array('0'=>300,'1'=>'Holland') ); when what is really required is an array that looks like this $countries = array( '100'=>'France', '200'=>'Germany', '300'=>'Holland' ); CroNiX already gave the solution in #17, so why are you muddying the water?
  19. I'd test for localhost otherwise remote.
  20. You need to to connect to the server before you can select a database. You also need to send the POST data from the form. Check that data has been posted before trying to use the posted data ( isset() )
  21. All you are doing in the code in insert.php is defining a string. You have to execute the query defined in that string.
  22. Those COUNTs need to be SUMs SELECT SUM(IF(level='P1',1, NULL)) 'P1', SUM(IF(level='P2',1, NULL)) 'P2', SUM(IF(level='P3',1, NULL)) 'P3' FROM faults
  23. Strange, then, that the examples in the manual have the colons http://php.net/manual/en/pdostatement.execute.php (examples #1, #2)
  24. So. There a 3 level 2 users (Tom, Tommy, Kim) so they each receive £4.50/3 (ie £1.50 each) There is 1 level 3 user (Henry) so he receives £13.50.
×
×
  • 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.