hi i have a problem i need to search my database for the registration number..the problem is i have 2 tables in that database such as cd and sd.. how can i search it?
i already have an idea its using textbox and combobox and a submit button but i dont how to implement it..please help me guyz thanks
here is the form
and this searchresult.ph p
i already have an idea its using textbox and combobox and a submit button but i dont how to implement it..please help me guyz thanks
here is the form
Code:
<form method="post" action="searcherresults.php"> <select name="table" size="1"> <option value="cd">cd</option> <option value="sd">sd</option> </select> <input type="text" name="search" size=25 maxlength=25> <input type="Submit" name="Submit" value="Submit"> </form>
and this searchresult.ph p
Code:
<?php $search=$_POST['search']; $table=$_POST['table']; $dbhost = 'localhost'; $dbuser = 'root'; $dbpass = ''; $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); $dbname = 'msic'; mysql_select_db($dbname); $sql = mysql_query ("SELECT * FROM '%{$table}%' WHERE Rnum LIKE '%{$search}%'"); while ($row = mysql_fetch_array($sql)){ echo 'ID: '.$row['Idko']; echo '<br/> Registration Number: '.$row['Rnum']; echo '<br/> Name: '.$row['Fname']; echo ' '.$row['Lname']; echo '<br/>Contact Number: '.$row['Contact']; echo '<br/>Rate: '.$row['Rate']; echo '<br/> Pick Up location: '.$row['Origin']; echo '<br/>Pick Up Date: '.$row['Pickday'] . $row['Pickmonth'] ; echo '<br/>Pick time: '.$row['Pickhr']; echo ' '.$row['Pickmin']; echo '<br/>Return Date: '.$row['Rday'] . $row['Rmonth'] ; echo '<br/>Return time: '.$row['Rhr'] ; echo ' '.$row['Rmin']; echo '<br/> Destination: '.$row['Destination']; echo '<br/> Vehicle Type: '.$row['Vehicle']; echo '<br/><br/>'; } ?>
Comment