oMIKEo Posted April 23, 2006 Share Posted April 23, 2006 Hi,Ive got a search page that im trying to code but cant work out how to do it...the search terms are:[b]Pupil [/b]- this is the pupils id OR the the word ALL to display all pupils.[b]View [/b]- these are 4 different types of reports that can be searched, if selected their values are 'Y' the boxes are [b]log, sen, lm, support[/b].[b]Dates [/b]- these are a from and to dates stored as, from_day, from_month, from_year, to_day, to_month, to_year.the database structure is:DATABASE: rhr_reportr_id - auto_incrementp_id - pupil id (should link to rhr_pupils table, get the 'name' using the p_id info)date - timestampnotesauthortype - either, log, sen, lm, support.How do you get it to display the table info from rhr_report and the pupils name from the rhr_pupils table based on what the user selects out of the terms?If they select ALL then it would need to display all the records based on 'dates' and the 'view'.So far ive got:[code] <?php $pupil= $_POST['pupil']; $log= $_POST['log']; $sen= $_POST['sen']; $lm= $_POST['lm']; $support= $_POST['support']; $from_day= $_POST['from_day']; $from_month= $_POST['from_month']; $from_year= $_POST['from_year']; $to_day= $_POST['to_day']; $to_month= $_POST['to_month']; $to_year= $_POST['to_year']; $conn=mysql_connect("$db_host","$db_username","$db_password") or die("Err:Conn"); $rs = mysql_select_db("$db_main",$conn) or die("Err:Db"); $sql="select * from rhr_report where p_id='$pupil'"; $rs=mysql_query($sql,$conn) or die("Could not execute query"); while($row=mysql_fetch_array($rs)) { echo ''.$row['p_id'].'<br />'; echo ''.$row['date'].'<br />'; echo ''.$row['author'].'<br />'; echo ''.$row['type'].'<br />'; echo nl2br (''.$row['notes'].''); } ?>[/code]Any help would be appreciated.Thank, Mike 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.