Jump to content

Help


rogerc

Recommended Posts

Hello

I am new to php and need some help,The code below is for selecting a record to delete through drop down list.I wonder could it be possible to change it text a box where you type a letter and all the records starting with it would be shown

 

thanks rogerc

 

<?

//start a session

session_start();

 

//check validity of user

if ($_SESSION[valid] != "yes"){

header("Location:http://127.0.0.1/contact_menu.php");

exit;

}

 

//set up table and database names

$db_name = "resultsdb";

$table_name = "grades";

 

//connect to server and select database

$connection = @mysql_connect("localhost") or die(mysql_error());

$db = @mysql_select_db($db_name,$connection) or die(mysql_error());

 

//build and issue query

$sql ="SELECT id, f_name, l_name FROM $table_name ORDER BY l_name";

$result = @mysql_query($sql,$connection) or die(mysql_error());

 

//check the number of results

$num = @mysql_num_rows($result);

 

if ($num < 1) {

//if there are no results,display message

$display_block = "<P><em>Sorry!No results.</em></p>";

 

} else {

 

//if results are found,loop through them

//and make a form selection block

while ($row =mysql_fetch_array($result)){

$id = $row['id'];

$f_name = $row['f_name'];

$l_name = $row['l_name'];

$option_block .="<option value=\"$id \">$l_name,$f_name</option>";

 

}

 

//create the entire form block

$display_block ="

<FORM METHOD=\"POST\" ACTION=\"show_delcontact.php\">

<P><strong>Student:</strong>

<select name=\"id\">

$option_block

</select>

 

<INPUT TYPE=\"SUBMIT\" NAME=\"submit\" VALUE=\"Select Student\"></P>

</form>";

 

}

?>

 

<HTML>

<HEAD>

<TITLE></TITLE>

</HEAD>

<BODY>

<h1></h1>

 

 

<P>Select Student Info from the list below.</P>

<? echo "$display_block"; ?>

 

<br>

<p><a href="contact_menu.php">Return to Main Menu</a></p>

</BODY>

</HTML>

Link to comment
https://forums.phpfreaks.com/topic/101046-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.