0
if(@$_GET['action'] == "Search"){
$result = mysql_query 
("SELECT * FROM students where
          idnum = '$_GET[mysearch]' or 
          fname = '$_GET[mysearch]' or 
          lname = '$_GET[mysearch]' or
          midin = '$_GET[mysearch]' or 
          gender = '$_GET[mysearch]' or 
          bdate = '$_GET[mysearch]' or
          course = '$_GET[mysearch]' or
          year = '$_GET[mysearch]' or
          address = '$_GET[mysearch]' or
          cnum ='$_GET[mysearch]'");
     $rows = mysql_num_rows($result);
     if ($rows != 0) {
        print "<table border=1 align=center>";
        print "<tr <td class=tdb>
                  <td><font size=3><center>Identification </center></font></td>
                  <td><font size=3><center>First Name</center></font></td>
                  <td><font size=3><center>Last Name</center></font></td>
                  <td><font size=3><center>Middle Initial</center></font></td>
                  <td><font size=3><center>Gender</center></font></td>
                  <td><font size=3><center>Birthdate</center></font></td>
                  <td><font size=3><center>Course</center></font></td>
                  <td><font size=3><center>Year</center></font></td>
                  <td><font size=3><center>Address</center></font></td>
          <td><font size=3><center>Contact Number</center></font></td>
          <td colspan=2><font size=3><center>Action</center></font></td></tr>";
        for ($i=0; $i< $rows; $i++) 
         {
           $row = mysql_fetch_row ($result);
           print "<tr>";
           print "<td><font size=3><center>$row[0]</center></font></td>";
           print "<td><font size=3><center>$row[1]</center></font></td>";
           print "<td><font size=3><center>$row[2]</center></font></td>";
           print "<td><font size=3><center>$row[3]</center></font></td>";
           print "<td><font size=3><center>$row[4]</center></font></td>";
           print "<td><font size=3><center>$row[5]</center></font></td>";
           print "<td><font size=3><center>$row[6]</center></font></td>";
           print "<td><font size=3><center>$row[7]</center></font></td>";
       print "<td><font size=3><center>$row[8]</center></font></td>";
       print "<td><font size=3><center>$row[9]</center></font></td>";
           print "<td>[ <a href=kalvin.php?action=Delete&idnum=$row[0]>Delete</a> ]";
              print "[ <a href=kalvin.php?action=Edit&idnum=$row[0]>Edit</a> ]";
           print "</td>";
           print "</tr>";
         }
        print "</table>";
        print "<font size=5>Number of entries found: $rows<br><button type=button onclick=history.back();>Back</button></font>";
     }
     else {
           print "<font size=5><center><blink>No records found!</blink><br><button type=button onclick=history.back();>Back</button></center></font>";
          }
     mysql_free_result ($result);
  }

Guys how can i modify this to make my search input can input letters and show all in my database containing those letter? :D thanks for any help guys.

2
Contributors
2
Replies
3
Views
4 Years
Discussion Span
Last Post by opawix
0

You can do one thing use textbox to input letters.
THen retrive textbox value and then put in the like clause of your select query
Ex:

"SELECT * FROM students where
idnum = '$_GET[mysearch]' or 
fname = '$_GET[mysearch]' or 
lname = '$_GET[mysearch]' or
midin = '$_GET[mysearch]' or 
gender = '$_GET[mysearch]' or 
bdate = '$_GET[mysearch]' or
course = '$_GET[mysearch]' or
year = '$_GET[mysearch]' or
address = '$_GET[mysearch]' or
cnum ='$_GET[mysearch]' and fname like '$_GET[textbox_val]"
0

thanks avinanuami, but what about i constraint the case. if i search lowercase letter it will only show lowercase letter save on database content.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.