I have two tables:
Speedtrap ---------- id (unique) state city location discription approval Comments --------- id (used to reference speedtrap id) comment_id (unique) email comment approval
Right now I can search and sort on the speedtraps according the the approval status "New,Yes,No" in the Speedtrap Table
if ($state eq 'all' && $status eq 'all') {$query = '';} if ($state ne 'all' && $status eq 'all') {$query = "WHERE state='$stat +e'"} if ($state eq 'all' && $status ne 'all') {$query = "WHERE approved='$s +tatus'"} if ($state ne 'all' && $status ne 'all') {$query = "WHERE state='$stat +e' AND approved='$status'";} $statement = "SELECT id,state,city,discription,approval FROM speedtrap + $query ORDER BY $sort1 $sortord"; $sth = $dbh->prepare($statement) or die "Couldn't prepare the query: " +.$DBI::errstr; $rv = $sth->execute or die "Couldn't execute query: ".$dbh->errstr; print <<EOF; <table border="1" align="center" width="100%"> <tr> <td width="1" height="1"> <p align="center">ID</p> </td> <td width="10%" height="1"> <p align="center">State</p> </td> <td width="20%" height="1"> <p align="center">City</p> </td> <td width="20%" height="1"> <p align="center">Discription</p> </td> <td width="1" height="1"> <p align="center">Speed Trap Approval</p> </td> <td width="70%" height="1"> <p align="center">Comment Approval</p> </td> </tr> EOF while (@row = $sth->fetchrow_array) { ($id,$state,$city,$discription,$approval) = @row; print <<EOF; <tr> <td width="1" height="1>$id</td> <td width="10%" height="1">$city</td> <td width="20%" height="1">$state</td> <td width="20%" height="1">$discription</td> <td width="1" height="1">$approval</td> <td width="70%" height="1">$need comment approval?</tr> EOF } print "</table>"; } $rc = $sth->finish; $rc = $dbh->disconnect;
How can I modify this so I can also query by "new,yes,no" on the approval column on the comment DB.

Thanks
Adam


In reply to Double Database Search and Sort by awohld

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.