Jump to content

NasimUddinAhmmad

New Members
  • Posts

    2
  • Joined

  • Last visited

NasimUddinAhmmad's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hello friends, I am a novice in php. Though I create 2 scripts: 1. students registration form 2. search students by Registration Number Our students' Registration Numbers are as follows: nifeA001, nifeA002 & so on... But when someone enter just "nife" or "n" or "A" etc all the students's data is showing. I want that students can search data by entering only Full Registration Number not a Part. I am placing the search.php code below. Please help me out.... ----------------- Search.php ------------------ <?php mysql_connect("localhost", "root", "") or die("could not connect"); mysql_select_db("student") or die("could not connect"); //collect if(isset($_POST['search'])) { $searchq = $_POST['search']; $searchq = preg_replace("#[^0-9a-z]#i", "", $searchq); //here $query = mysql_query("SELECT * FROM user WHERE registration LIKE '%$searchq%'") or die("could not search!"); $count = mysql_num_rows($query); if($count == 0){ $output = 'There was no search results!'; }else{ while($row = mysql_fetch_array($query)) { $fname = $row['firstname']; $lname = $row['surname']; $id = $row['registration']; $output .= '<div> '.$id.' '.$fname.' '.$lname.'</div>'; } } } ?> <html> <head> </head> <body> <form action="form.php" method="post"> <input type="text" name="search" placeholder="search for students.." <input type="submit" value=">>" /> </form> <?php print("$output");?> </body> </html>
×
×
  • 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.