Jump to content

hahaitwork

Members
  • Posts

    98
  • Joined

  • Last visited

Everything posted by hahaitwork

  1. Will check those links out Quick update: managed to get the 1,2,3,4,5, etc working.. http://loff-production.com/highscores/avoid-the-cars.html 1. Name. score 2. name. score 3. name score
  2. ah.. i see, well I tried to add that now and got this.. Warning: mysqli::mysqli(): (42000/1044): Access denied for user 'loff_production'@'%' to database 'high_scores_avoidthecars' in /customers/a/3/f/loff-production.com/httpd.www/avoidthecars/highscore.php on line 9 Warning: mysqli::query(): Couldn't fetch mysqli in /customers/a/3/f/loff-production.com/httpd.www/avoidthecars/highscore.php on line 21 Fatal error: Call to a member function fetch_assoc() on a non-object in /customers/a/3/f/loff-production.com/httpd.www/avoidthecars/highscore.php on line 22 Just to update you guys.. It's just the sorting that needs to be done, check out http://forums.phpfreaks.com/topic/271954-loading-only-tables-that-contain-text/ for an update, will close this in a few days. It's easier to follow the other threat
  3. So I tried that "WHERE" thingy.. not 100% where to put it but I thougth and I guessed Behind OR in front of "ORDER by" and got errors hmm.. $result = mysql_query("SELECT name, score FROM high_scores_avoidthecars ORDER BY score DESC WHERE name != '' ");
  4. uh.. really ? ;o I got select under? to select the database if that is the one you are looking for ?
  5. Mind explaining it a little? WHERE name !="? The !="? part I guess it ain't hard to get what it do.. but I don't see the connection about the ! and the " and ?
  6. Sorry, Pretty newbie at this forum.. I searched but didn't find a member with the name "Jessica"?
  7. Okey, my script is working mostly as I want. I need a line that picks top 50, and only choose those who submitted with name, if the name plate is blank.. the score should not come up. Here is the line I guess you have to change: $result = mysql_query("SELECT name, score FROM high_scores_avoidthecars ORDER BY score DESC "); Things that should work: 1. Sort out who got the highest score BUT also who submitted it first (checks highest/lowest id) (The lowest id number is also the one that sumbitted first*) 2. Top 50 scores only 3. Only show scores that have a Name submitted as well. Extra note: I have already a thread that is a bit the same, but will keep both open a little then close the other one. Here is the second thread that will be closed in a few days
  8. ahh.. I just copied what I had to connect.. my bad Will try it again! Here is what I tried, got error on line 22 this time (which is the marked text) Fatal error: Call to a member function fetch_assoc() on a non-object in /customers/a/3/f/loff-production.com/httpd.www/avoidthecars/highscore.php on line 22 <html> <head> <link href="styleofc.css" rel="stylesheet" type="text/css"> </head> <?php $mysqli = new mysqli("x","x","x"); $sql="SELECT @rownum := @rownum + 1 AS Rank , name as Name , score as Score , id as ID FROM high_scores_avoidthecars JOIN (SELECT @rownum := 0) as initialise ORDER BY score DESC, id LIMIT 50"; $res = $mysqli->query($sql); $row = $res->fetch_assoc(); <-------------- LINE 22! <------------------------------- echo "<table border='1'><tr><th>" . join('</th><th>', array_keys($row)) . "</th></tr>\n"; do { echo "<tr><td>" . join('</td><td>', $row) . "</td></tr>\n"; } while ($row = $res->fetch_assoc()) ; echo "</table>\n" ; $res->free(); ?> </html>
  9. Error: Fatal error: Call to a member function query() on a non-object in /customers/a/3/f/loff-production.com/httpd.www/avoidthecars/highscore.php on line 25 Line 25: $res = $mysqli->query($sql);
  10. I do not have a date but I do have "ids" so, the lowest id will be the first that was submitted anyhow. I know how I want it, the problem is i'm not sure how to write the script .. =)
  11. http://loff-production.com/highscores/avoid-the-cars.html Here is what I got at the moment. 1. I need numbers next to the players name (hopefully in a own little table) left of the name. 2. I need them sorted after best score, but ALSO after who submitted first of those with the same score.
  12. Ehm, how come it got so silence? was it because my answer was totally wrong, or because people got unsure about what it could be? if it is a easy edit some how, any idea how I could make it say like ? | 1 | *name* | *score* | | 2 | *name* | *score* | | 3 | *name* | *score* | | 4 | *name* | *score* | That means, somehow add 1-50 on the side of the name and score
  13. Score = int id = int if that is what you mean?
  14. Anymore info you could give me about what you think is wrong ?
  15. None of them worked actually.. could be because it doesn't select id.. let me retry. $result = mysql_query("SELECT id, name, score FROM high_scores_avoidthecars ORDER BY score DESC, id LIMIT 50 "); Tried this.. still not working as it should >_<
  16. You mean like: ORDER BY score DESC, id DESC, LIMIT 50"); Even if that is correct it won't sort them the rigth way.
  17. ORDER BY score DESC, id DESC 50"); like this? Not working. seems abit special as well?
  18. I know that coders will wrist in pain when they see it but for me it works perfectly and I'm not going to change it for this "project" Your code made NO change actually What is "ASC" by the way?
  19. I need the script to sort it after score, but also after id, because the person on top should be the first person that submitted the score. like if someone got id 13, score 15 and someone later gets id 34 and score 15, it should be the person with id 13 that is on Top. Any ideas? I think it could be something like "BY score, id" or so? tride that but then it ended up the showing the ID and score the wrong way. $result = mysql_query("SELECT name, score FROM X ORDER BY score DESC LIMIT 50"); echo "<table border='20' width='450px'> <tr> <th>Name</th> <th>Score</th> </tr>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" .'&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp'. $row['name'] .'&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp'. "</td>"; echo "<td>" .'&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp'. $row['score'] .'&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp'. "</td>"; echo "</tr>"; } echo "</table>"; mysql_close($con); ?> </html>
  20. Thanks and yeah, I'm rarily using this stuff but it sure would be handy to know it.
  21. Hello, I need the script to be able to only pick the 50 best scores, and not every score that is submitted. Any idea? It has to be the 50 best of course, not just randomly 50. Is it something that can be fixed with > or is it abit more advance code? <html> <head> <link href="styleofc.css" rel="stylesheet" type="text/css"> </head> <center> <div style="position:absolute; margin-left:450px; margin-top:0px; TOP:100px; color:#D8D8D8;" border="2" > <?php $con = mysql_connect("loff-production.com.mysql","loff_production","v4rANidp"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("loff_production", $con); $result = mysql_query("SELECT name, score FROM high_scores_avoidthecars ORDER BY score DESC"); echo "<table border='20'> <tr> <th>Name</th> <th>Score</th> </tr>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" .'&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp'. $row['name'] .'&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp'. "</td>"; echo "<td>" .'&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp'. $row['score'] .'&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp'. "</td>"; echo "</tr>"; } echo "</table>"; mysql_close($con); ?> </div> </center> </html>
  22. Thanks I did find a script to sort it actually but it sorted the wrong way so thanks for your script! ehm, true.. sry I forgot about the code tags.
  23. Hello, I'm loading data from my database but now I need them sorted as well, after "score". I need the highest score to be on the top, and let's say it shows a total of 50. that means if someone have 100 score, and rest is 99-10 and the last is 1.. I want 100 on top, 1 on buttom and 99-10 between.. bet you understood it Any ideas? my script is this so far: <?php $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("my_db", $con); $result = mysql_query("SELECT * FROM members"); echo "<table border='1'> <tr> <th>Name</th> <th>Score</th> </tr>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['name'] . "</td>"; echo "<td>" . $row['score'] . "</td>"; echo "</tr>"; } echo "</table>"; mysql_close($con); ?>
  24. Okey.. I understood it better now, but I'm not sure how to fix it as my script is like this: This is mainly the parts with + and - and remove. Tried a few things but ending up with errors, it's mostlying trying to set <a name="x"></a> and call it insted of using the $page if (isset ($_GET['add'])) { $quantity = mysql_query ('SELECT id, quantity FROM products WHERE id=' .mysql_real_escape_string ((int) $_GET ['add'])); while ($quantity_row = mysql_fetch_assoc ($quantity)) { if ($quantity_row['quantity'] !=$_SESSION['cart_'.(int)$_GET['add']]) { $_SESSION['cart_'.(int)$_GET['add']]+='1'; } } header('Location: '.$page); } if (isset($_GET['remove'])) { $_SESSION['cart_'.(int)$_GET['remove']]--; header('Location: '.$page); } if (isset($_GET['delete'])) { $_SESSION['cart_'.(int)$_GET['delete']]='0'; header('Location: '.$page); } echo "<p style='width:250px; float:left;'>". '<table border="1" >'.'<tr>'.'<td WIDTH="250px" HEIGHT="80px" float:left; ">'.'<center>'.$get_row['name'].'<br />'.$get_row['description'].'</center>'.'</td>'.'</tr>'.'<td WIDTH="60%" HEIGHT="50px" ">'.'<center>'.' x '.$ids[$get_row['id']].' * €'.number_format ($get_row['price'],0).' = €'.number_format($sub, 0). '</td>'.'</tr>'.'<tr>'.'</center>'.'<tr>'.'<td WIDTH="200px" HEIGHT="0px"'.'<center>' .'&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp <a href="cart.php?remove='.$get_row['id'].'"><img src="subtract.png" border="0" style="height: 20px; width: 35px" ></a> &nbsp&nbsp <a href="cart.php?add='.$get_row['id'].'"><img src="pluss.png" border="0" style="height: 20px; width: 35px" ></a> &nbsp&nbsp <a href="cart.php?delete='.$get_row['id'].'"><img src="delete.png" border="0" style="height: 20px; width: 50px" ></a></p>' .'</center>' .'</td>' .'</tr>' .'</td>'.'</tr>'.'</table>';
×
×
  • 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.