I am not quite sure how to ask this. I have a search script that works good for my db. What I need to be able to do is have a checkbox giving the user the option to update or delete the row. How would I go about doing this. Please help me out.
I am very new to this, I had help with this script.
Here is my search script:
<html>
<head><title>Search</title></head>
<body><p>
<h4>
<a href="insert2.php" target="_self" name="">Return to DB Homedb Home</a>
</h4></p>
<?php
// Full-Text Search Example
// Connect to the database.
$cnx = mysql_connect('localhost', '*****', '*****') or die ("Could not connect");
mysql_select_db('testdb', $cnx) or die (mysql_error());
// Create the search function:
function searchForm()
{
// Re-usable form
// variable setup for the form.
$searchwords = (isset($_GET['words']) ? htmlspecialchars(stripslashes($_REQUEST['words'])) : '');
$normal = (($_GET['mode'] == 'normal') ? ' selected="selected"' : '' );
$boolean = (($_GET['mode'] == 'boolean') ? ' selected="selected"' : '' );
echo '<form method="get" action="'.$_SERVER['PHP_SELF'].'">';
echo '<input type="hidden" name="cmd" value="search" />';
echo 'Search for: <input type="text" name="words" value="'.$searchwords.'" /> ';
echo 'Mode: ';
echo '<select name="mode">';
echo '<option value="normal"'.$normal.'>Normal</option>';
echo '<option value="boolean"'.$boolean.'>Boolean</option>';
echo '</select> ';
echo '<input type="submit" value="Search" />';
echo '</form>';
}
// Create the navigation switch
$cmd = (isset($_GET['cmd']) ? $_GET['cmd'] : '');
switch($cmd)
{
default:
echo '<h1>Search Database!</h1>';
searchForm();
break;
case "search":
searchForm();
echo '<h3>Search Results:</h3><br />';
$searchstring = mysql_escape_string($_GET['words']);
switch($_GET['mode'])
{
case "normal":
$sql = "SELECT id, coords, name, owner,
MATCH(coords, name, owner)
AGAINST ('$searchstring') AS score FROM planets
WHERE MATCH(coords, name, owner)
AGAINST ('$searchstring') ORDER BY score DESC";
break;
case "boolean":
$sql = "SELECT id, coords, name, owner,
MATCH(coords, name, owner)
AGAINST ('$searchstring' IN BOOLEAN MODE) AS score FROM planets
WHERE MATCH(coords, name, owner)
AGAINST ('$searchstring' IN BOOLEAN MODE) ORDER BY score DESC";
break;
}
// echo $sql;
$result = mysql_query($sql) or die (mysql_error());
while($row = mysql_fetch_object($result))
{
echo '<strong>Coords: '.stripslashes(htmlspecialchars($row->coords)).'</strong><br />';
echo '<strong>Name: '.stripslashes(htmlspecialchars($row->name)).'</strong><br />';
echo '<strong>Owner: '.stripslashes(htmlspecialchars($row->owner)).'</strong><br />';
echo '<hr size="1" />';
}
break;
}
?>
</body>
</html>