I've been working on a review site for a while now, i just finished writing the review submission form and now im writing the review display part (products.php) but im having some issues with it. Here's my code:
This is the page of the script: http://raemag.com/products.phpCode:<?php $databaseserver = "localhost"; $databasename = "raemagc_reviews"; //the name of your database on the mysql server $databaseuser = "raemagc_admin"; //the name of the database-user $databasepass = "pass"; // the password to database $db = mysql_connect($databaseserver, $databaseuser, $databasepass); mysql_select_db($databasename,$db); if(!mysql_select_db("raemagc_reviews", $db)) { die("DATABASE SELECTION FAILED"); } function ratings ($id){ $query="SELECT * FROM `gratings` WHERE id = `$id`"; $res = mysql_query($query); if(!$res){ die ("Couldn't execute select query?! Something's gone horribly wrong."); } $numrows = mysql_num_rows($res); $feature = 0; $sound = 0; $action = 0; $realiability = 0; $suppert =0; $overall = 0; while($arr = mysql_fetch_array($res, MYSQL_ASSOC)) { $feature .= $arr[featurerating]; $sound .= $arr[soundrating]; $action .= $arr[actionrating]; $reliability .= $arr[reliabilityrating]; $support .= $arr[supportrating]; $overall .= $arr[overallrating]; } $e_feature = $feature / $numrows; $e_sound = $sound / $numrows; $e_action = $action / $numrows; $e_reliability = $reliability / $numrows; $e_support = $support / $numrows; $e_overall = $overall / $numrows; echo " <table width=\"281\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\"> <tr class=\"font_grey\"> <td width=\"140\"><strong>Features </strong></td> <td width=\"136\">$e_feature<</td> </tr> <tr class=\"font_grey\"> <td><strong>Sound </strong></td> <td>Sound: $e_sound </td> </tr> <tr class=\"font_grey\"> <td><strong>Action, Fit, & Finish </strong></td> <td>Action: $e_action </td> </tr> <tr class=\"font_grey\"> <td><strong>Reliability/Durability </strong></td> <td>Reliability: $e_reliability </td> </tr> <tr class=\"font_grey\"> <td><strong>Customer Support </strong></td> <td>Support: $e_support</td> </tr> <tr class=\"font_grey\"> <td><strong>Overall Rating </strong></td> <td>Overall: $e_overall</td> </tr> </table> "; } if (isset($manufacturer)){ if (isset($model)){ if (isset($review)){ $query="SELECT * FROM `greviews` WHERE id = `$_GET[review]`"; $res = mysql_query($query); if(!$res) die ("Couldn't execute select query?! Something's gone horribly wrong."); $numrows = mysql_num_rows($res); while($arr = mysql_fetch_array($res, MYSQL_ASSOC)) { echo " <table><tr> "; ratings($arr[$_GET[review]]); echo " <p align=\"center\"><strong>Submit a review for this product!</strong></p> </td> </tr> <tr> <td align=\"left\" valign=\"top\" class=\"font_grey\"><p> </p> <p>Price Paid: $arr[pricepaid]<br> <br> Purchased from: $arr[purchasedfrom]<br> <br> Features:$arr[featurerating]<br> $arr[features] <br> <br> Sound:$arr[soundrating]<br> $arr[sound] <br> <br> Action, Fit, & Finish:$arr[actionrating]<br> $arr[action] <br> <br> Reliability/Durability: $arr[reliabilityrating]<br> $arr[reliability] <br> <br> Customer Support: $arr[supportrating]<br> $arr[support]<br> <br> Overall Rating: $arr[overallrating]<br> $arr[overall] <br> <br> Submitted by:$arr[show] (if "yes"show)post: (if no show)post: Anonymous<br> Name:$arr[name]<br> E-mail:$arr[email]<br> </p> <p> </p></td> </tr> </table> "; } } else { $query="SELECT * FROM `greviews` WHERE parent_id = `$_GET[model]`"; $res = mysql_query($query); if(!$res) die ("Couldn't execute select query?! Something's gone horribly wrong."); $numrows = mysql_num_rows($res); while($arr = mysql_fetch_array($res, MYSQL_ASSOC)) { echo " Review: <a href=?manufacturer=$_GET[manufacturers]&models=$_GET[models]&review=$arr[id]>Review</a><br> "; } } } else { $maker = $_GET[manufacturer]; $query="SELECT * FROM `gmodels` WHERE parent_id=$maker"; $res = mysql_query($query); if(!$res) die ("Couldn't execute select query?! Something's gone horribly wrong."); $numrows = mysql_num_rows($res); while($arr = mysql_fetch_array($res, MYSQL_ASSOC)) { $parent = $arr["parent_id"]; $models = $arr["models"]; echo " Model: <a href=?manufacturer=$parent &models=$models>$models</a><br> "; } } } else { $query="SELECT * FROM `gmanufacturers`ORDER BY manufacturers"; $res = mysql_query($query); if(!$res) die ("Couldn't execute select query?! Something's gone horribly wrong."); $numrows = mysql_num_rows($res); while($arr = mysql_fetch_array($res, MYSQL_ASSOC)) { echo " Manufacturer: <a href=?manufacturer=$arr[id]>$arr[manufacturers]</a><br> "; } } ?>
The manufacturers and models show perfectly, but i cant get the link to the reviews to work, which is this part:
Any help is much appreciated!Code:$maker = $_GET[manufacturer]; $query="SELECT * FROM `gmodels` WHERE parent_id=$maker"; $res = mysql_query($query); if(!$res) die ("Couldn't execute select query?! Something's gone horribly wrong."); $numrows = mysql_num_rows($res); while($arr = mysql_fetch_array($res, MYSQL_ASSOC)) { $parent = $arr["parent_id"]; $models = $arr["models"]; echo " Model: <a href=?manufacturer=$parent &models=$models>$models</a><br> "; }




Bookmarks