scm22ri Posted June 29, 2012 Share Posted June 29, 2012 Hi Everyone, I'm relatively new to PHP. I want to give my users the ability to write reviews of businesses that are located on my website but I'm not sure how to implement the code. In the below URL I want my users to click on the name of the business and be able to write a review of such business. I'm not asking anyone to write the code for me but what I am asking is this, what's the next process? How do I attack/solve this program I'm having. What do I do next .... Thanks everyone. http://whatsmyowncarworth.com/practiceTemplate/practice1/33/loans/table3.php <?php include('init.php'); /*$sql = "SELECT * FROM cars WHERE id='1' ORDER BY year ASC";*/ $sql = "SELECT * FROM dealers"; if ($result = mysql_query($sql)) { echo "<table border='1'>"; echo "<tr> <th>Name</th> <th>Address</th> <th>State</th> <th>City</th> <th>Website</th> "; // keeps getting the next row until there are no more to get while ($row = mysql_fetch_array($result)){ $name = $row['name']; $address = $row['address']; $state = $row['state']; $city = $row['city']; $website = $row['website']; $maps = $row['maps']; $lat = $row['lat']; $lng = $row['lng']; echo("\t<tr>\n"); echo("\t\t<td>" . "<a href='http://$website' target = '_blank'>" . "$name" . "</a></td>\n"); echo("\t\t<td>" . "$address" . "</td>\n"); echo("\t\t<td>" . "$state" . "</td>\n"); echo("\t\t<td>" . "$city" . "</td>\n"); echo("\t\t<td>" . "<a href='http://$website' target = '_blank'>" . "$name" . "</a></td>\n"); /*echo("\t\t<td>" . "<a href='http://$website' target = '_blank'>" . "$name" . "</a></td>\n"); echo("\t\t<td>" . "<a href='http://$maps' target = '_blank'>" . "$address" . "</td>\n"); echo("\t\t<td>" . "<a href='http://$maps' target = '_blank'>" . "$address" . "</td>\n"); echo("\t\t<td>" . "$state" . "</td>\n"); echo("\t\t<td>" . "$city" . "</td>\n"); echo ("\t\t<td>" . "<a href='http://$website' target = '_blank'>" . "$website" . "</a></td>\n"); echo("\t\t<td>" . "$maps" . "</td>\n"); echo("\t\t<td>" . "$lat" . "</td>\n"); echo("\t\t<td>" . "$lng" . "</td>\n");*/ // Print out the contents of each row into a table } echo "</table>"; } else { trigger_error(mysql_error()); // for development only; remove when in production } ?> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body bgcolor="#FFFFFF" text="#000000"> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/265007-customer-review-section-in-php/ Share on other sites More sharing options...
jcbones Posted June 29, 2012 Share Posted June 29, 2012 1. Build a page that holds a form to insert a customers review into the database, specifying the company by it's unique key. 2. Link to the page using a $_GET parameter (unique key) that specifies the company. 3. Pull the reviews back to your original page with a database query, using the unique key to specify the company/ies. It looks like you have the database queries down, so things you need to look at are. $_GET You should have a table in your database similar to: CREATE TABLE IF NOT EXISTS `reviews` ( `id` int(11) NOT NULL AUTO_INCREMENT, `user_id` int(11) NOT NULL, `comment` text NOT NULL, `review_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `yes` int(4) NOT NULL DEFAULT '0', `no` int(4) NOT NULL DEFAULT '0', PRIMARY KEY (`id`) ); You can add a column if you need to approve reviews before they are shown. Quote Link to comment https://forums.phpfreaks.com/topic/265007-customer-review-section-in-php/#findComment-1358028 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.