Jump to content

Barand

Moderators
  • Posts

    24,602
  • Joined

  • Last visited

  • Days Won

    830

Everything posted by Barand

  1. Which of those two fields should match the value in $id_number? (If the answer is both, why are you storing it twice?)
  2. Which of those two fields should match the value in $id_number? (If the answer is both, why are you storing it twice?)
  3. Which of your tables contains "id_number" column. You didn't mention that before (I assume that "password" and "status" are in the voters table)
  4. I confess I am not sure how your scoring is implemented and how it really fits into the model. Would the score be related to the work_xxxxxx tables? I agree with Psycho that those statements imply hierarchy
  5. It sounds like the attached model would serve and would allow "work" definitions such as +-----------+-----------+--------------+--------+-----------+ | work_name | Division | Company | Team | Project | +-----------+-----------+--------------+--------+-----------+ | Work 1 | Southeast | | | | | Work 1 | Northwest | | | | | Work 1 | | | Team 3 | | | Work 1 | | | Team 2 | | | Work 1 | | | Team 1 | | +-----------+-----------+--------------+--------+-----------+ | Work 2 | Northeast | | | | | Work 2 | | Danish Bacon | | | | Work 2 | | Body Shop | | | | Work 2 | | | Team 3 | | | Work 2 | | | Team 2 | | +-----------+-----------+--------------+--------+-----------+ | Work 3 | | Ajax Stores | | | | Work 3 | | | | Project C | | Work 3 | | | | Project A | +-----------+-----------+--------------+--------+-----------+ All I have to do now is figure out how to get your averages from that structure
  6. Perhaps this is an occasion for separate queries. How different are the tables?
  7. $sql = "SELECT item_id , category , sub_category , sub_sub_category , name , price FROM items ORDER BY category, sub_category, sub_sub_category"; $res = $db->query($sql); $data = array(); while (list($id, $cat, $subcat, $subsubcat, $name, $price) = $res->fetch_row()) { $data [$cat][$subcat][$subsubcat][$id] = ['name'=>$name, 'price'=>$price]; }
  8. The fields in each column should be of matching types too
  9. If you do a union like that then select dummy fields in the table with less data SELECT a, b, c FROM tablea UNION SELECT x, y, NULL as c FROM tableb
  10. This is the same problem you posted in your other thread. Apply the same technique I gave you there. http://forums.phpfreaks.com/topic/294644-how-to-create-query-in-log-in-that-compares-the-id-using-php/?do=findComment&comment=1505910 Or do you want us to write the code for you every time?
  11. Don't try building the json string in the query. Store query results in the array structure you want then json_encode that.
  12. As cyberRobot had already told him to check the file locations a couple of times before you chimed in then no biscuit this time
  13. The id of the logged-in voter who wants to see the candidates in his/her organization. I have no idea how you are storing it and what your variable is but I thought that was a self-explanatory name for example purposes.
  14. No surprises there. If the username and password were wrong for mysqli then they will still be wrong for a PDO connection. You need to check the usernames and password on the server.
  15. Your code "dies" if there is *not* an error! So you therefore echo "success" but the error gets displayed anyway Note: You can also specify the database with a 4th parameter in your connection.
  16. Change it to ON c.org_id = v.org_id
  17. I would have thought the relation table redundant in this scenario. It look like a hierarchy +-------------+ | division | +-------------+ +------------+ | div_id |-----+ | team | | div_name | | +------------+ +------------+ +-------------+ | | team_id |-----+ | score | | | team_name | | +------------+ +-----<| div_id | | | score_id | +------------+ +-----<| team_id | | date | | score | +------------+
  18. something like this SELECT c.firstname , c.lastname FROM candidates c INNER JOIN voters v USING (org_id) WHERE v.voters_id = $loggedInID
  19. or $message = "$nonce$token{$path}0.1buy965.45"; $path requires the {..} to prevent it being interpreted as $path0 which would be a valid variable name
  20. You can use the MySQL function STR_TO_DATE() to convert your dates to the correct format SELECT sale_date FROM `customer-sale` WHERE STR_TO_DATE(sale_date,'%d/%m/%Y') BETWEEN '2015-02-05' AND '2015-02-10' You can use that same function in an UPDATE query to convert your dates to the correct format. Add new DATE type column to store the correct format then UPDATE `customer-sale` SET newdate = STR_TO_DATE(sale_date, '%d/%m/%Y')
  21. As you have been told by myself and mac_gyver, if an organisation has multiple courses, those courses would not go in the organisation table.
  22. The set up you describes is the first in the three below. The one you probably want is the third ORGANISATION COURSE ------------ ------------ (MANY-to-ONE) org_id +----- course_id courses are org_name | course_name run by many org_description | organisations course_id >----+ ORGANISATION COURSE ------------ ------------ (ONE-to-MANY) org_id -----+ course_id organisations org_name | course_name run many org_description +----< org_id courses ORGANISATION ORG_COURSE COURSE (MANY-to-MANY) ------------ ------------ ----------- organisations run org_id ---+ id +--- course_id many course and org_name +-< org_id | course_name courses run by course_id >--+ many organisations
  23. If you want to find overlapping dates then use a query like this SELECT a.room_id as rooma , a.start_date as starta , a.end_date as enda , b.room_id as roomb , b.start_date as startb , b.end_date as endb FROM book a INNER JOIN book b ON a.end_date > b.start_date AND a.start_date < b.end_date AND a.room_id < b.room_id
  24. What is the code you have tried so far?
  25. try $arr = json_decode('{"bids": [[ 100, 24 ], [ 300, 10 ], [ 200, 34 ]], "asks": [[ 300, 23 ], [ 100, 34 ], [ 200, 21]]}', 1); rsort($arr['bids']); sort($arr['asks']); echo '<pre>',print_r($arr, true),'</pre>';
×
×
  • 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.