Jump to content

extrovertive

Members
  • Posts

    235
  • Joined

  • Last visited

    Never

Everything posted by extrovertive

  1. Ok, output your IP. And now output all the IPs in the loop.
  2. $result = mysql_query("SELECT * FROM blog ORDER BY date ASC") or die(mysql_error());
  3. Have you tried  if(strstr($myip,$banned_ip)) ?
  4. Maybe her IP has changed if it's dynamic. Try adding your current IP to the database now.
  5. I don't know what column you're using for your date stamp, but just change "date" below to what you have for your date column. $result = mysql_query("SELECT * FROM blog ORDER BY date") or die(mysql_error());
  6. You're welcome.  If only I spotted the $_GET error eariler  :D
  7. [code=php:0] $myip = $_SERVER['REMOTE_ADDR']; $addr = mysql_query("SELECT ip FROM bans"); while ($ip = mysql_fetch_assoc($addr)) { $banned_ip = $ip['ip']; if(strstr($myip,$banned_ip)) {   print ("Error Message");   exit;   } } [/code]
  8. I think I see another problem, which I fixed. You were using $_GET['id'], shouldn't it be $qry['id'] ??? Here's the revised version: [code=php:0] <!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 print "<table border=1 class=list>"; echo("<thead><tr><td>Site Name</td><td>Editor Rating</td><td>Visitor Rating</td><td>Date Added</td><td>Publisher</td></tr></thead><tbody>"); $result = mysql_query('SELECT * FROM site ORDER BY name DESC'); while ($qry = mysql_fetch_array($result)) { print "<tr>"; print "<td><a href=site.php?id=$qry[id]>$qry[name]</td>"; //Assuming each editorrating correpsonding an image name w/ that rating $image = $qry['editorrating'] . '.png'; //Display user's rating image echo "<td><img src=\"images/{$image}\" /></td>"; //Get User's ID rating and display rating image based on that rating $id = $qry['id']; $qry_rating = mysql_query("SELECT rating FROM site where id='$id'");            list($rating) = mysql_fetch_row($qry_rating); $new_rating2 = (string)$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>"; //Display dateadded print "<td>$qry[dateadded]</td>"; //Display publisher print "<td>$qry[publisher]</td>"; print "</tr>"; } print "</tbody></table>"; ?> <p>&nbsp;</p> <p>&nbsp;</p> </body> </html> [/code]
  9. For my test script above, did you try that one? $id = $_GET['id']; $id = 10; You're saying my test script above thousands of: "Visitor Rating: 1.25 (Correct image for 1.25 also shown next to each one)" but all ID are unique right? Try taking the while loop out: [code=php:0] $id = $_GET['id']; $id = 10; $qry_rating = mysql_query("SELECT rating FROM site WHERE id = '$id'");    list($rating) = mysql_fetch_row($qry_rating); $new_rating2 = (string)$rating; print "Visitor 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}\" />"; [/code] And if the display is correct for ID 10, then you can try to implement that code portion in your full script (removing the "$id = 10;" of course)
  10. [code=php:0] $userid = $_GET['user']; if($userid) { $sql  = "SELECT * "; $sql .= "FROM style "; $sql .= "WHERE user_id = '$userid' "; $result = mysql_query($sql) or die (mysql_error()); if(mysql_num_rows($result) == 1) { $row = mysql_fetch_array($result);             } [/code] What happens now?
  11. Ok, so ID = 10 displays has a 1.25 rating right? [code=php:0] $id = $_GET['id']; $id = 10; while($qry_rating = mysql_query("SELECT rating FROM site WHERE id = '$id'")) {      list($rating) = mysql_fetch_row($qry_rating); $new_rating2 = (string)$rating; print "Visitor 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}\" />"; } [/code] And the image path is correct, right?
  12. Looks fine to me. Perhaps refreshing your browser and did you save the code?
  13. Looks fine to me. You're using: [code=php:0] 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}\" />"; } [/code] Right?
  14. Seems like it works. Try this: [code=php:0] //$id = $_GET['id']; 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}\" />"; } [/code]
  15. What's the ID of someone with a rating of 1.25? Add this to the test script: [code=php:0] $id = $_GET['id']; $id = (ID that person w/ a rating of 1.25); $qry_rating = mysql_query("SELECT rating FROM site where id='$id'");            list($rating) = mysql_fetch_row($qry_rating); $new_rating2 = (string)$rating; print $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 print $image2 = $rateA[0] . $rateA[1] . '.png'; [/code] And tell me if the rating an image displays.    
  16. I see the problem now. Below $new_rating2 = $rating; in the code I wrote: put $new_rating2 = (string)$rating;
  17. But you have a rating column in your table right? Let's do a simple test script: [code] $qry_rating = mysql_query("SELECT rating FROM site");            while(list($rating) = mysql_fetch_row($qry_rating)) { echo $rating . "<br/ >"; } [/code] Try that.
  18. Here's what you need to learn about comments. One comment in PHP // are mainly use for describing something brief about something in your code. //loop variable to display names //This variable will increment by 3 each every Wednesday and so on... Multi-line comment can be used for fancy stuff needing a lot explanation in your source code. /*************** * Title: My code * Author: me! * Date: Today * Program: PHP prog. * Descripton: Blah blah blah... **************/ /* Function: Blah @params: $one - it does this $two - it does that Blah blah... */ Avoid using comments which state the obvious. //this is a for-loop
  19. K, it seems the query is not getting anything for the $rating variable. There's a `rating` column in your `site` table right? Would you mind doing a test script to see if the below code works? $id can be set any ID that's in your site table (I assume there's an ID 17). $id = $_GET['id']; //test $id = 17; $qry_rating = mysql_query("SELECT rating FROM site where id='$id'");            list($rating) = mysql_fetch_row($qry_rating); $new_rating2 = $rating; echo $new_rating2;
  20. Hmmm...all ID are unique right, with each ID containing only 1 rating? Like ID 23 has a rating of 2.57 once? Try this... //Get User's ID rating and display rating image based on that rating $id = $_GET['id']; $qry_rating = mysql_query("SELECT rating FROM site where id={$id}");            list($rating) = mysql_fetch_row($qry_rating); $new_rating2 = $rating; echo $new_rating2 and tell me if it's display something. If it does, the rest should work.
  21. Are you talking about this portion? [code=php:0] print "<tr>"; print "<td><a href=site.php?id=$qry[id]>$qry[name]</td>"; //Assuming each editorrating correpsonding an image name w/ that rating $image = $qry['editorrating'] . '.png'; //Display user's rating image echo "<td><img src=\"images/{$image}\" /></td>"; [/code] Try echoing $image to show display if there's something or not.
  22. I commented on some line. Uncomment them. <?php //include("includes/dbconnect.php"); ?> Should be <?php include("includes/dbconnect.php"); ?> And the line below was: ("<thead><tr><td>Site Name</td><td>Editor Rating</td><td>Visitor Rating</td><td>Date Added</td><td>Publisher</td></tr></thead><tbody>"); //$result = mysql_query('SELECT * FROM site ORDER BY name DESC'); Uncomment that $result = mysql_query('SELECT * FROM site ORDER BY name DESC');
×
×
  • 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.