Jump to content

Customer Review Section? in PHP


scm22ri

Recommended Posts

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>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.