Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 170
  • Last Modified:

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

0
paddy086
Asked:
paddy086
1 Solution
 
Ray PaseurCommented:
Is there anything more to the code?  For example, how do you set the variables $i and $options?
0
 
paddy086Author Commented:
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

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now