wwfc_barmy_army
Members-
Posts
320 -
Joined
-
Last visited
Never
Everything posted by wwfc_barmy_army
-
Thanks for the great reply! I have managed to kinda implementate this now, although i've got one problem, if i enter the page normally i get this error: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\public_html\RPG\list.php on line 28 (Line 28 being the one in bold below - Part of the code below)(i have commented out the other lines until i get it working properly:)): [code]if (isset($_GET['sortid'])) { switch ($_GET['sortid']) { case 0 : $column = 'name'; break; case 1 : $column = 'editorrating'; break; default : $column = 'name'; } } $result = mysql_query("SELECT * FROM site ORDER BY $column DESC"); //$allowed = array ( 'name', 'editorrating', 'dateadded', 'publisher' ); //$column = ( in_array ( $_GET['sortby'], $allowed ) ? $_GET['sortby'] : 'name, editorrating, dateadded, publisher'); //$result = mysql_query ( 'SELECT * FROM site ORDER BY ' . $column . ' DESC' ) or die ( 'Query Error: ' . mysql_error () ); //$result = mysql_query('SELECT * FROM site ORDER BY name DESC'); [b]while ($qry = mysql_fetch_array($result))[/b] {[/code] So i get to the page but included '?sortid=0' and it worked fine, it looks like for some reason it gets confused about it and it looks like the actual word $column is getting passed. Any ideas on how i can get around this? Thanks. Peter.
-
Hehe. No Worries. Thanks again! Pete.
-
SUPER! It works! Thanks for all your help extrovertive. You've been great! Much appreciated! Thanks. Peter.
-
*sighs*, it worked fine in the test script then when i put it in the list.php code, it just shows the broken image /images/.png. Is another bit of the code messing it up? Thanks. Peter,
-
Yes, thats right, this shows thousands of these: Visitor Rating: 1.25 (Correct image for 1.25 also shown next to each one). Thanks. Peter.
-
ahh, didn't save it properly. But it crashed my IE, just kept on coming up with the image for number 4 and some writing next to it saying something like visitor number 4 ??? Peter.
-
Yup using: <?php include("includes/dbconnect.php"); while($qry_rating = mysql_query("SELECT rating FROM site")) { list($rating) = mysql_fetch_row($qry_rating); $new_rating2 = (string)$rating; print "Vistor Rating: " . $new_rating2 . " "; //gets the average rating from the database and put into an image variable $rateA = explode(".", $new_rating2); $rateA[1] = ((int)$rateA[1] <= 49) ? NULL : $rateA[1]; $rateA[1] = ((int)$rateA[1] >= 50 && (int)$rateA[1] <= 99) ? "5" : $rateA[1]; //store rating in image2 variable $image2 = $rateA[0] . $rateA[1] . '.png'; //Display user's rating image2 print "<img src=\"images/{$image2}\" />"; } ?>
-
Parse error: parse error, unexpected T_STRING in C:\public_html\RPG\test.php on line 11 Line 11 being: print "Vistor Rating: " . $new_rating2 . " "; Thanks. Peter.
-
Sorry where am i putting this? Thanks. Peter.
-
Outputs: 1.251.png (the ID is 10 :)) Thanks. Peter.
-
:( still the same problem Thanks. Peter.
-
Yup, got the rating column in the site table :) The test gives: 4 0 0 0 0 0 0 0 1.25 0 0 Thanks. Peter.
-
Just shows a '0' :) Thanks for your help so far. Peter.
-
I just had a look in IE instead of firefox and i can now see that it has broken images, all 'http://localhost/rpg/images/.png'. Yes, each record has a different ID and all have 1 rating. We tried doing echo $new_rating; but it didn't show anything. Thanks. Peter.
-
I'm talking about the visitor rating: //Get User's ID rating and display rating image based on that rating $qry_rating = mysql_query("SELECT rating FROM site where id='$_GET[id]' LIMIT 1"); list($rating) = mysql_fetch_row($qry_rating); $new_rating2 = $rating; //gets the average rating from the database and put into an image variable $rateA = explode(".", $new_rating2); $rateA[1] = ((int)$rateA[1] <= 49) ? NULL : $rateA[1]; $rateA[1] = ((int)$rateA[1] >= 50 && (int)$rateA[1] <= 99) ? "5" : $rateA[1]; //store rating in image2 variable $image2 = $rateA[0] . $rateA[1] . '.png'; //Display user's rating image2 echo "<td><img src=\"images/{$image2}\" /></td>"; Thanks. Peter.
-
Thanks. Got it now :) Thanks. Peter.
-
Great. Although there are no images for the 'Visitor Rating'. Peter.
-
Wow, thanks. Although i am getting this error: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\public_html\RPG\list.php on line 17 Line 17 being: while ($qry = mysql_fetch_array($result)) Thanks. Peter.
-
I've tried that but it still says the same. Note: The lines that the error is coming from are: $qry = mysql_fetch_array($result); and while ($qry = mysql_fetch_array($result)) Thanks. Peter.
-
They are all showing 0 stars for some reason. We've made it so at least 2 of them should show stars. Peter.
-
But only if it's less that the next if statement isn't it? It works in my another page we have. Thanks. Peter.
-
Thanks for your reply. Although i am getting this error: [quote]Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\public_html\RPG\list.php on line 15 Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\public_html\RPG\list.php on line 19[/quote] My code changed from when i posted, here is the new stuff: [code]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <?php include("includes/dbconnect.php"); ?> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>View Sites</title> </head> <body> <?php $allowed = array('name','Blah'); $column = (in_array($_GET['sortby'], $allowed)) ? $_GET['sortby'] : 'name'; $result = mysql_query('SELECT * FROM site ORDER BY $column DESC'); //$result = mysql_query('SELECT * FROM site ORDER BY name DESC'); $qry = mysql_fetch_array($result); print "<table border=1 class=list>"; echo("<thead><tr><td><a href=list.php?sortby=name>Site Name</a></td><td>Editor Rating</td><td>Visitor Rating</td><td>Date Added</td><td>Publisher</td></tr></thead><tbody>"); while ($qry = mysql_fetch_array($result)) { print "<tr>"; print "<td><a href=site.php?id=$qry[id]>$qry[name]</td>"; switch ($qry['editorrating']) { case 0: $image = "0.png"; break; case 1: $image = "1.png"; break; case 2: $image = "2.png"; break; case 3: $image = "3.png"; break; case 4: $image = "4.png"; break; case 5: $image = "5.png"; break; case 12: $image = "05.png"; break; case 15: $image = "15.png"; break; case 25: $image = "25.png"; break; case 35: $image = "35.png"; break; case 45: $image = "45.png"; break; } echo "<td><img src=\"images/{$image}\" /></td>"; print "<td></td>";// edited line print "<td>$qry[dateadded]</td>"; print "<td>$qry[publisher]</td>"; print "</tr>"; } print "</tbody></table>"; ?> <p> </p> <p> </p> </body> </html>[/code] Any advice? Thanks. Peter.
-
How could i make a rating system *solved*
wwfc_barmy_army replied to Renlok's topic in PHP Coding Help
There are a couple of rating tutorials around on the internet you could check out some of them. If you can't find a good one lemme know and i'll find the one i used. Peter. -
Hello, I have this code: [quote]<?php $result = mysql_query('SELECT name, sitelink, sitedownload, dateadded, publisher FROM site ORDER BY name DESC'); print "<table border=1 class=list>"; echo("<thead><tr><td>Site Name</td><td>Site Link</td><td>Site Download</td><td>Date Added</td><td>Publisher</td></tr></thead><tbody>"); while ($qry = mysql_fetch_array($result)) { print "<tr>"; print "<td>$qry[name]</td>"; print "<td><a href=$qry[sitelink]>$qry[sitelink]</a></td>"; print "<td><a href=$qry[sitedownload]>$qry[sitedownload]</a></td>"; print "<td>$qry[dateadded]</td>"; print "<td>$qry[publisher]</td>"; print "</tr>"; } print "</tbody></table>"; ?>[/quote] It is currently listed by 'name' although, i am trying to find a way that i can make it so that when i click on one the of table headers it sorts that column. The headers are here: [quote]<thead><tr><td>Site Name</td><td>Site Link</td><td>Site Download</td><td>Date Added</td><td>Publisher</td></tr></thead><tbody>[/quote] Any advice is appreciated. Thanks. Peter.
-
Anyone?