Jump to content

search help


oMIKEo

Recommended Posts

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_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
notes
author
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");
                    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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.