Jump to content

Barand

Moderators
  • Posts

    24,565
  • Joined

  • Last visited

  • Days Won

    822

Everything posted by Barand

  1. 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.
  2. 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.
  3. 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.
  4. Change it to ON c.org_id = v.org_id
  5. 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 | +------------+
  6. something like this SELECT c.firstname , c.lastname FROM candidates c INNER JOIN voters v USING (org_id) WHERE v.voters_id = $loggedInID
  7. 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
  8. 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')
  9. 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.
  10. 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
  11. 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
  12. What is the code you have tried so far?
  13. 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>';
  14. Also, mysqli_fetch_array() will not execute the query.
  15. You would do it in the function on return of the ajax response as you have been shown in reply #49 http://forums.phpfreaks.com/topic/294097-data-from-a-table/page-3?do=findComment&comment=1504950
  16. That is javascript. Repeat to yourself several hundred times, or until it sinks in, "PHP runs on the server, javascript runs on the client"
  17. A MySql type TIMESTAMP is not a unix-style timestamp but yyyy-mm-dd hh-ii-ss format. Try SELECT TIMESTAMPDIFF(MINUTE, event, NOW()) as time1 , dht22temp , humidity , pressure FROM sensordata WHERE event > NOW()-INTERVAL 2 HOUR ORDER BY Time
  18. String values need to be inside single quotes in a query $select_u = mysql_query("SELECT * FROM `users` WHERE `city` = '$pilseta' ");
  19. Your original code had the right parameters for mysqli but you forgot the "i" when you called the functions, using mysql_query() instead of mysqli_query() etc
  20. Have a go at VB. You'll want to throw yourself out of the window
  21. This function $zodiacPictures($imgCounter) You need [..] for array indexes. (..) is for functions [edit] Using foreach() would be easier foreach ($zodiacPictures as $src){ echo '<img src="' . $src . '" />'; } and there are no </img> tags
  22. You need to GROUP BY city_name with that query
  23. Is there a common key in both table to relate the records or do you want the same total to appear on every output row
  24. is this the result you are looking for? $results = '{"bids": [[0.010010000, 150.000000000], [0.121000000, 82.000000000]], "asks": [[1700.000000000, 1.000000000],[282.365000000, 1.000000000]]}'; $arr = json_decode($results, 1); $asks = $arr['asks']; sort($asks); echo $asks[0][0]; //--> 282.365
  25. By default, json_decode returns an object as you have done $obj=json_decode($result); So to access "low" you would use $low = $obj->low; If you want an array then you need the second argument of json_decode to be true EG $array = json_decode($result, 1); Then you can access low with $low = $array['low'];
×
×
  • 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.