Link to home
Start Free TrialLog in
Avatar of paddy086
paddy086Flag for Ireland

asked on

php delete sql

Hi on my form it pulls the data from a SQL database and displayes it in a drop down box on the web site i want the name that is displayed to be deleated from the Sql database can some one help me with the code thanks

<p><form action="delete.php" method="POST"> 
<?php include('php.php'); ?>
<!-- Use <pre> to preserve layout --> 

<pre> 
Pease enter Teachers Name for Deleated 
Teachers Name:     <select name="sickteacher[<?php echo $i ?>]"><?php echo $options ?></select><br><br>  
</pre> 

<input type="submit" value="Add"> 
<input type="reset" value="Reset"> 

</form>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of paddy086

ASKER

sorry the included php.php script is here
 
<?php 

// Connect to server 
// Replace username and password by your details  

$db = @mysql_connect("localhost","root","iqonr301"); 
if (!$db) 
{ 
        do_error("Could not connect to the server"); 
} 


// Connect to the database 
// Note that your database will be called username 

@mysql_select_db("test",$db)or do_error("Could not connect to the database"); 

//connect to db first
$options = '';
$teachers = mysql_query('SELECT * FROM teacher ORDER BY name ASC');
while($teacher = mysql_fetch_array($teachers)) {
     $options .= sprintf("<option value='%s'>%s</option>", $teacher['name'], $teacher['name']);
}
$class_options = '';
$classes = mysql_query('SELECT * FROM class');
while($class = mysql_fetch_array($classes)) {
     $class_options .= sprintf("<option value='%s'>%s</option>", $class['name'], $class['name']);
}
$room_options = '';
$rooms = mysql_query('SELECT * FROM room');
while($room = mysql_fetch_array($rooms)) {
     $room_options .= sprintf("<option value='%s'>%s</option>", $room['number'], $room['number']);
}
$subject_options = '';
$subjects = mysql_query('SELECT * FROM subject');
while($subject = mysql_fetch_array($subjects)) {
     $subject_options .= sprintf("<option value='%s'>%s</option>", $subject['name'], $subject['name']);
}
?>

Open in new window