Jump to content


This topic is now archived and is closed to further replies.


search help

Recommended Posts


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_report

r_id - auto_increment
p_id - pupil id (should link to rhr_pupils table, get the 'name' using the p_id info)
date - timestamp
type - 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");
                        echo ''.$row['p_id'].'<br />';
                        echo ''.$row['date'].'<br />';
                        echo ''.$row['author'].'<br />';
                        echo ''.$row['type'].'<br />';
                        echo nl2br (''.$row['notes'].'');
Any help would be appreciated.

Thank, Mike

Share this post

Link to post
Share on other sites


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.