Jump to content

Barand

Moderators
  • Posts

    24,605
  • Joined

  • Last visited

  • Days Won

    831

Everything posted by Barand

  1. ... WHERE MONTH(exrdate) = MONTH(CURDATE()) AND YEAR(exrdate) = YEAR(CURDATE())
  2. exrdate is not a function. SELECT SUM(job_cost) as job_cost, SUM(profit) as profit FROM repairs WHERE exrdate >= CURDATE() - INTERVAL 1 MONTH
  3. You need two separate SUM()s SELECT SUM(job_cost) as job_cost, SUM(profit) as profit .....
  4. That will only get those who were born today, not whose birthday falls today. SELECT username , pdob , YEAR(CURDATE())-YEAR(pdob) as age FROM table WHERE MONTH(pdob)=MONTH(CURDATE()) AND DAY(pdob)=DAY(CURDATE())
  5. then $beneficiary = 123; // or whatever $bank_data = array ( array($branchId1 , $acc1), array($branchId2 , $acc2) ); $sql = "INSERT INTO user_bank (beneficiary_id, branch_id, account VALUES (?,?,?))"; $stmt = $db->prepare($sql); $stmt->bind_param('ii', $benficiary,$branch, $acc); foreach ($bank_data as $bdata) { list($branch, $acc) = $bdata; $stmt->execute(); }
  6. If your bank_branch table stores the bank_id then you don't need it in user_bank table.
  7. When using prepared statements in a situation like this you define query, prepare and bind parameters once only. After doing that, loop through the data values to set the parameters and execute. $beneficiary = 123; // or whatever $bank_data = array ( $branchId1 , $branchId2 ); $sql = "INSERT INTO user_bank (beneficiary_id, branch_id VALUES (?,?))"; $stmt = $db->prepare($sql); $stmt->bind_param('ii', $benficiary, $branch); foreach ($bank_data as $branch) { $stmt->execute(); }
  8. I did not say that would work. Read my reply again. I said "if you restructure your data and use arrays then you could reduce it to something like that". It was an example of what might be possible, not code for you to blindly copy/paste into your existing code.
  9. As soon as you see something like "position1, position2, position3,...,positionN" or "seat1, seat2,..., seatN" then that is a clue that something is wrong. You should be using arrays. That mass of if() statements could then be reduced to something like foreach ($seatnumbers->results()as $seatresults) { $seats=$seatresults->seat[$q]; }
  10. SELECT IFNULL(paid_status, 'Some Text') as paid_status FROM depanarecuora_clients
  11. I am having difficulty seeing any connection between your query and the question
  12. So, is it working? You need to tell us something.
  13. Or, as in this case, on the actual line number stated in the message
  14. No. If you do that then the form will not be displayed. It should extend to the end of that PHP code that should be processed only if data is posted.
  15. You check if $_POST{'submit'] is set but that that check ends at line 51. All the code that is dependent on it being set needs to be inside the {..}
  16. I would recommend using a datepicker component in your form, if you aren't already. Expecting all users to enter consistent date formats will lead to disappointment, also you get confusion with text field dates. Is 06-07-2015 in d-m-Y format or is it m-d-Y? With a datepicker you can display (and post) the same format every time. I usually set my datepickers to display 07-Jun-2015 format which is universally understood by users and is unambiguous. What's more it unambiguous and understood by the PHP strtotime() function and DateTime class. $d = new DateTime('07-Jun-2015'); echo $d->format('Y-m-d'); // 2015-06-07 echo date('Y-m-d', strtotime('07-Jun-2015')); // 2015-06-07
  17. You are having problems yet you comment out those lines. Unbelievable!.
  18. Having seen your data reminded me you need to join on SectorDate too. Mk III version SELECT * FROM ( SELECT Dep as depA , BeginTime as deptimeA , Arr as arrA , EndTime as arrtimeA , SectorDate FROM rosters WHERE Dep='MAN' AND BeginTime > '03:00' AND SectorDate = '2015-11-26' ) a LEFT JOIN ( SELECT Dep as depB , BeginTime as deptimeB , Arr as arrB , EndTime as arrtimeB , SectorDate FROM rosters ) b ON arrA = depB AND arrtimeA < deptimeB AND a.SectorDate = b.SectorDate LEFT JOIN ( SELECT Dep as depC , BeginTime as deptimeC , Arr as arrC , EndTime as arrtimeC , SectorDate FROM rosters ) c ON arrB = depC AND arrtimeB < deptimeC AND b.SectorDate=c.SectorDate WHERE 'DUB' IN (arrA, ArrB, ArrC)
  19. But you still use them in your code
  20. I was wondering if it was your airport roster table. There are not many departure and destination points in that table that have a value of "A" or "Z".
  21. Barand

    Rank

    There is no need for the $table table. Just get the data from the SELECT query. For the rank, just maintain a counter as you output the rows. $sql = "SELECT a.playersid as Entry , b.name as Name , sum(a.points) as Points , sum(a.payout) as Winnings , sum(a.high_hand) as HH , sum(a.fifty_fifty) as Fty , sum(attend) as Attend FROM data a INNER JOIN players b ON a.playersid = b.playersid GROUP BY Entry ORDER BY Points DESC"; $res = mysql_query($sql); $row = mysql_fetch_assoc($res); $heads = "<tr><th>Rank</th><th>" . join('</td><td>', array_keys($row)) . "</th></tr>\n"; $rank=1; $tdata=''; do { $tdata .= "<tr><td>$rank</td><td>" . join('</td><td>', $row) . "</td></tr>\n"; $rank++; } while ($row = mysql_fetch_assoc($res)); ?> <table border='1'> <?php echo $heads, $tdata;?> </table> And stop using mysql_ functions (See my signature)
  22. Can you post an sql dump of your rosters table?
  23. Have you ever considered looking at the PHP reference manual? http://uk1.php.net/manual/en/language.operators.arithmetic.php http://uk1.php.net/manual/en/language.operators.assignment.php
  24. Mk II version SELECT * FROM ( SELECT depart as depA , dep_time as deptimeA , arrive as arrA , arr_time as arrtimeA FROM journey WHERE depart='A' AND dep_time > '03:00' ) a LEFT JOIN ( SELECT depart as depB , dep_time as deptimeB , arrive as arrB , arr_time as arrtimeB FROM journey ) b ON arrA = depB AND arrtimeA < deptimeB LEFT JOIN ( SELECT depart as depC , dep_time as deptimeC , arrive as arrC , arr_time as arrtimeC FROM journey ) c ON arrB = depC AND arrtimeB < deptimeC WHERE 'Z' IN (arrA, ArrB, ArrC);
  25. try SELECT projectid as project , SUM(IF(Status_ID=1, 1,0)) as passed , SUM(IF(Status_ID=2, 1,0)) as failed FROM tbltesttransactions GROUP BY projectid
×
×
  • 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.