Ok Im making a review script for my site, and I need a little help.
First, I made add.php
[php]<?php
$location = "localhost";
$username = "username";
$password = "pass";
$database = "db";
$conn = mysql_connect("$location","$username","$password");
if (!$conn) die ("Could not connect MySQL");
mysql_select_db($database,$conn) or die ("Could not open database");
mysql_query("CREATE TABLE reviews (
review_name VARCHAR(20),
basic_plot VARCHAR(80),
review VARCHAR(100),
email VARCHAR(20),
poster_url VARCHAR(20),
publisher VARCHAR(20),
author VARCHAR(30))");
if($submit); {
$insert = "INSERT INTO reviews (review_name,basic_plot,review,email,poster_url,publisher,author)
VALUES (\'$review_name\',\'$basic_plot\',\'$review\',\'$email\',\'$poster_url\',\'$publisher\',\'$author\')";
mysql_query($insert) or die ("Could not add data to the table");
}
?>[/PHP]
On this one, im making an edit.php and delete.php, and I have to use ID\'s to make them work. How do you get this ID stuff in.
Then theres list.php
[PHP]
<?php
$location = "localhost";
$username = "username";
$password = "pass";
$database = "db";
$conn = mysql_connect("$location","$username","$password");
if (!$conn) die ("Could not connect MySQL");
mysql_select_db($database,$conn) or die ("Could not open database");
$query = "SELECT * FROM reviews";
$result = mysql_query($query);
$numrows = mysql_num_rows($result);
while($row = mysql_fetch_array($result)){
print("We have <b>$numrows</b> reviews in our database <p>");
}
?>
<?
$query = "SELECT * FROM reviews";
$result = mysql_query($query);
$numrows = mysql_num_rows($result);
while($row = mysql_fetch_array($result)){
echo "<b>$row[review_name]</b><br>";
}
?>
[/PHP]
Well since Im a newbie, I dont know how to stop this. For all the test reviews I put, after every one, it says, \"We have X many reviews in the DB\", but I only want it to show once. Also, how do you link it to the review.
Thanks!