php adding a button/analysing
i have a db that stores film and film reviews and using php i have created a system where the user can search for a review and then a list of reviews appear, i want to create a button with each review so that when selected the individual review can be analysed this will search the review to see how many positive and negative words it has
this is the code for my review.php
<?php
$searching=$_POST['searching'];
$searchfilm=$_POST['searchfilm'];
//If form is submitted
if ($searching =="yes")
{
echo "<h2>Film Review</h2><p>";
//If field is empty send a message
if ($searchfilm == "")
{
echo "<p>You forgot to enter a search term";
echo
exit;
}
//Connect to database
mysql_connect("nmnm", "jkjk", "mnm") or die(mysql_error());
mysql_select_db("nmnnm") or die(mysql_error());
//Filter search
$searchfilm = strtoupper($searchfilm);
$searchfilm = strip_tags($searchfilm);
$searchfilm = trim ($searchfilm);
//Qyery database
$data = mysql_query("SELECT film.filmname, review.filmreview, review.reviewtitle FROM film, review WHERE film.filmid = review.filmid AND filmname = '$searchfilm'");
//$result = mysql_query($data) or die(mysql_error());
//Display film title searched for
echo "<b>Film Name:</b> " .$searchfilm;
echo "<p>";
//Display results
while($row = mysql_fetch_array($data))
{
// echo $row['filmname'];
// echo "<b>Film Name:</b> " .$searchfilm;
echo "<table border=\"2\" align=\"left\">";
echo "<tr><td>";
echo "<b>Review Title:</b> " .$row['reviewtitle'];
echo "<tr><td>";
echo $row['filmreview'];
echo "<p>";
echo "<form method='post' action='analyse.php'>";
echo "<tr><td><input type='submit' name='analyse' value='Analyse'/></td></tr>";
echo "</form>";
echo "</table>";
}
//If result doesn't exist give an error message
$anymatches = mysql_num_rows($data);
if ($anymatches == 0)
{
echo "Your request could not be processed, please enter a valid search<br><br>";
}
}
?>
i am unsure is i have added the button correctly to the display results section too
any help would be appreciated
Related Article: submit button doesnt run php code
is a solved PHP discussion thread by hwoarang69 that has 21 replies, was last updated 1 year ago and has been tagged with the keywords: php, html, css.
cr7489
Junior Poster in Training
53 posts since Dec 2011
Reputation Points: 25
Solved Threads: 0
Skill Endorsements: 0
im not getting any error messages but unsure of adding a button that would allow each review to be analysed
cr7489
Junior Poster in Training
53 posts since Dec 2011
Reputation Points: 25
Solved Threads: 0
Skill Endorsements: 0
the reason for the button is so that when selected the individual review is analysed by finding the number of negative and positive words to determine the type of review and these words are stored in my db
cr7489
Junior Poster in Training
53 posts since Dec 2011
Reputation Points: 25
Solved Threads: 0
Skill Endorsements: 0
this is because its a system for a user therefore they wouldn't know to click the review its easier to have a button
cr7489
Junior Poster in Training
53 posts since Dec 2011
Reputation Points: 25
Solved Threads: 0
Skill Endorsements: 0
does any body know how the button can created to be unique with each review ?
cr7489
Junior Poster in Training
53 posts since Dec 2011
Reputation Points: 25
Solved Threads: 0
Skill Endorsements: 0
as the filmreview needs analysing would this not be it ? as the film id would just identify the review against the film ?
cr7489
Junior Poster in Training
53 posts since Dec 2011
Reputation Points: 25
Solved Threads: 0
Skill Endorsements: 0
something like this:
echo "<tr><td>" . "<form action='tabletest.php' method='post' onsubmit='return confirmSubmit()'>" . "<input type='hidden' value='" . $row['filmreview'] . "' name='film'>" . "<input type='submit' value='Analyse'>" . "</form>" . "</td></tr>";
cr7489
Junior Poster in Training
53 posts since Dec 2011
Reputation Points: 25
Solved Threads: 0
Skill Endorsements: 0