Jump to content

Barand

Moderators
  • Posts

    24,602
  • Joined

  • Last visited

  • Days Won

    830

Everything posted by Barand

  1. You could run a query to count the jonsmiths SELECT COUNT(*) as count FROM user WHERE username LIKE 'johnsmith%' Append the returned count to the username, so first gets johnsmith, second gets johnsmith1 etc In addition, add a UNIQUE constraint to the username column. In the event two johnsmiths register simultaneously you will then get an error, in which case repeat the process.
  2. pseudocode get input for each array element if matches input print bold else print plain end if end for
  3. Could be because galI_id in the ORDER BY is ambiguous and I put the WHERE after ORDER (Ooops!) Try SELECT gallery.gal_id , gname , img_id , img_name FROM gallery INNER JOIN images ON images.gal_id=gallery.gal_id WHERE gallery.user_id = $whatever ORDER BY gallery.gal_id DESC LIMIT $eu,$limit
  4. Put a check in there $ch = curl_init('https://btc-e.com/api/3/depth/ltc_btc'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HEADER, false); $result = curl_exec($ch); if (!$result) { exit("cURL failed"); } $array = json_decode($result, 1); $asks = $array['ltc_btc']['asks']; sort($asks); echo '<pre>', print_r($asks, true), '</pre>';
  5. Have you added a new line 16 and forgotten the ; at the end of the line?
  6. $data = '{"ltc_btc":{"asks":[[0.00757,109.7613],[0.00758,83.72171025]],"bids":[[0.00754,0.782],[0.00753,283.68702632],[0.00752,608.06368173],[0.00751,1058.66307725],[0.0075,692.06028608]]}}'; $arr = json_decode($data, 1); $asks = $arr['ltc_btc']['asks']; sort($asks); echo '<pre>',print_r($asks, true),'</pre>'; result Array ( [0] => Array ( [0] => 0.00757 [1] => 109.7613 ) [1] => Array ( [0] => 0.00758 [1] => 83.72171025 ) )
  7. in your code echo mysql_num_rows($row); should be echo mysql_num_rows($result);
  8. It was working when it left the shop EG mysql> SELECT * FROM test_time; +------------+ | time | +------------+ | 1424476800 | | 1424480400 | | 1424484000 | | 1424487600 | | 1424491200 | | 1424494800 | | 1424498400 | | 1424502000 | | 1424505600 | | 1424509200 | | 1424512800 | | 1424516400 | | 1424520000 | | 1424523600 | | 1424527200 | | 1424530800 | | 1424534400 | | 1424538000 | | 1424541600 | | 1424545200 | | 1424548800 | | 1424552400 | | 1424556000 | | 1424559600 | +------------+ mysql> SELECT -> time -> , FROM_UNIXTIME(time) -> FROM test_time -> WHERE HOUR(NOW()) = HOUR(FROM_UNIXTIME(time)); +------------+---------------------+ | time | FROM_UNIXTIME(time) | +------------+---------------------+ | 1424556000 | 2015-02-21 22:00:00 | +------------+---------------------+
  9. Well no, you have to replace the "..."
  10. Seems easier to select those where the current hour matches the hour they signed up SELECT ... WHERE HOUR(NOW()) = HOUR(FROM_UNIXTIME(opt_time))
  11. In which case you would use $asks = $array['ltc_btc']['asks'];
  12. And even if they were, they would be arrays and not string values. I find if difficult to see how you came up with that code after requinix gave you the working solution
  13. How many times do we have to answer this question for you? http://forums.phpfreaks.com/topic/294604-sorting-multidimensional-array/?do=findComment&comment=1505682
  14. SELECT gallery.gal_id , gname , img_id , img_name FROM gallery INNER JOIN images ON images.gal_id=gallery.gal_id ORDER BY gal_id DESC WHERE gallery.user_id = $whatever LIMIT $eu,$limit
  15. DISTINCT is not a function - it applies to the whole row and not a single field. It is also redundant when using GROUP BY. If you don't know how the images relate to users, how the hell do you expect us to know when we don't even know what your data looks like?
  16. Why the double sets of quotes?
  17. I gave you the idea - you do a JOIN on org_id to get records with matching values in that column
  18. looks like a unix time value Try SELECT FROM_UNIXTIME(last_post) FROM topics
  19. You do the check on line 4. Do the same on line 3.
  20. This will calculate the averages SELECT div_name as division , '' as company , '' as team , '' as project , AVG(s.score) as av_score FROM division d LEFT JOIN work_division wd ON d.division_id = wd.division_id LEFT JOIN score s ON wd.work_id = s.work_id GROUP BY d.division_id UNION SELECT '' as division , c.co_name as company , '' as team , '' as project , AVG(s.score) as av_score FROM company c LEFT JOIN work_company wc ON c.company_id = wc.company_id LEFT JOIN score s ON wc.work_id = s.work_id GROUP BY c.company_id UNION SELECT '' as division , '' as company , t.team_name as team , '' as project , AVG(s.score) as av_score FROM team t LEFT JOIN work_team wt ON t.team_id = wt.team_id LEFT JOIN score s ON wt.work_id = s.work_id GROUP BY t.team_id UNION SELECT '' as division , '' as company , '' as team , p.proj_name as project , AVG(s.score) as av_score FROM project p LEFT JOIN work_project wp ON p.project_id = wp.project_id LEFT JOIN score s ON wp.work_id = s.work_id GROUP BY p.project_id; Results: +-----------+--------------+--------+-----------+----------+ | division | company | team | project | av_score | +-----------+--------------+--------+-----------+----------+ | Northeast | | | | | | Northwest | | | | 6.0000 | | Southeast | | | | 6.6667 | | Southwest | | | | | | | Ajax Stores | | | 9.0000 | | | Body Shop | | | 6.0000 | | | Culpepper | | | | | | Danish Bacon | | | 5.3333 | | | | Team 1 | | 6.6667 | | | | Team 2 | | 6.8000 | | | | Team 3 | | 6.0000 | | | | | Project A | 7.6000 | | | | | Project B | | | | | | Project C | 9.0000 | | | | | Project D | | +-----------+--------------+--------+-----------+----------+
  21. $conn = new PDO("mysql:host=$servername;$db", $user_name, $password); $stmt = $db->prepare("INSERT INTO Products(NAME, DESCRIPTION, PRICE, IMAGE, TYPE, MADE, DISTRIBUTE) Your PDO object is $conn.
  22. If you don't know code from data then you are beyond help. Bye.
  23. Not without seeing your data and how it is really set up
  24. That's what the JOIN on the org_id is for. Then you would only use that column in the query SELECT v.id_number , c.firstname , c.lastname , c.image FROM candidates c INNER JOIN voters v ON v.org_id = c.org_id WHERE id_number='$id_number' AND password='$password' AND status='Unvoted'
  25. What? Please tell tell that's a typing error.
×
×
  • 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.