How do add functionality to my add button and my modify button? (php and sql help...

  • Thread starter Thread starter eoin b
  • Start date Start date
E

eoin b

Guest
...needed)? <HTML>
<HEAD>
<TITLE>Alarm Codes</TITLE>
</HEAD>

<body>
<font face="ARIAL"><h1 align = "CENTER">Alarm Codes</h1>
<center>
<form name= "alarm" method="post" action="alarm_codes.php">
<table border = "0">
<tr><td>Alarm Code:</td>
<td><input type="TEXT" name="alarm" size="40"/> </td>
</tr>
<tr><td>Alarm Description:</td>
<td><input type="TEXT" name="description" size="60"/></td>
</tr>
</table>
<input type="hidden" name="searching" value="" />
<input type="submit" name="search" value="Search" />
<input type="submit" name="add" value="Add" />
<input type="submit" name="modify" value="Modify" />
<p>
<p>
</form>




<?php

// Otherwise we connect to our Database
//include('db_login.php');
$connection = mysql_connect("localhost", "alarm", "") or die (mysql_error());

mysql_select_db (alarm_codes);

$find = $_POST['alarm'];
echo $_POST['searching'];
//This is only displayed if they have submitted the form
if ($_POST['searching']=="")

//If they did not enter an alarm we give them an error
if ($find == ""){
echo "<p>You forgot to enter an alarm code </p>" ;
exit;
}

// We preform a bit of filtering
$find = strtoupper($find);
$find = strip_tags($find);
$find = trim ($find);
//Now we search for our search term, in the field the user specified
$sql = "select * from codes where codes like '%" . $find . "%' ";
$data = mysql_query($sql);

echo ("<b>Searched For:</b><br> " .$find . "\n" );



//And we display the results
while($result = mysql_fetch_array( $data)) {
echo '<br><h3>Result: <br></h3> '.$result;
echo $result['codes'] . "<p><br> " . $result['description'] ."<p\><br\>" ;
}





//This counts the number or results - and if there wasnt any it gives them a little message explaining that
$anymatches=mysql_num_rows($data);
if ($anymatches==0)

echo "Sorry, but we can not find an entry to match your query. Please add this alarm<br><br>\n";



//And we remind them what they searched for

"mysql_free_result";
("mysql_close");

?>
</center>
</body>
</html>
i need the add button to add alarm codes to the database and modify button to modify alarm codes already in the database
 
Back
Top