awohld has asked for the wisdom of the Perl Monks concerning the following question:
Right now I can search and sort on the speedtraps according the the approval status "New,Yes,No" in the Speedtrap TableSpeedtrap ---------- id (unique) state city location discription approval Comments --------- id (used to reference speedtrap id) comment_id (unique) email comment approval
How can I modify this so I can also query by "new,yes,no" on the approval column on the comment DB.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;
Thanks
Adam
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Double Database Search and Sort
by JediWizard (Deacon) on Sep 24, 2004 at 21:33 UTC | |
by awohld (Hermit) on Sep 25, 2004 at 03:54 UTC | |
|
Re: Double Database Search and Sort
by ikegami (Patriarch) on Sep 24, 2004 at 21:29 UTC | |
by awohld (Hermit) on Sep 25, 2004 at 04:22 UTC | |
by ikegami (Patriarch) on Sep 25, 2004 at 04:58 UTC |