rogerc Posted April 15, 2008 Share Posted April 15, 2008 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 its been wrecking my head for yonks i have no idea how to fix it any help would be greatly appreciated this is the code for it. 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>Sorry!No results.</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"; ?> <p><a href="contact_menu.php">Return to Main Menu[/url]</p> </BODY> </HTML> Quote Link to comment Share on other sites More sharing options...
benphp Posted April 15, 2008 Share Posted April 15, 2008 Can you rephrase the question? I don't understand. Punctuation and capitalization would help too. Quote Link to comment Share on other sites More sharing options...
rogerc Posted April 15, 2008 Author Share Posted April 15, 2008 hi I need to change the drop down box to a text box so that i can serach the database by the keyboard eg if I press A all the records starting with A would show up if that could be done thanks Quote Link to comment Share on other sites More sharing options...
MatthewJ Posted April 15, 2008 Share Posted April 15, 2008 Roger, You may want to just start from scratch as what you are requesting is quite a change to the way things are currently laid out in your script. Basic logic would be to build a form that submits the desired letter... build a query to get the results of the search, display them with a delete link/button at the end of each field that would point to a confirmation page with the unique ID for that row appended to the end of the confirmation page URL. When someone comfirms the delete, remove the record from the database. Hope that helps get you started, Matt Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.