CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Beginner:
I want to check a value in the loop.



Jun 21, 2000, 11:20 AM

Post #1 of 1 (530 views)
I want to check a value in the loop. Can't Post

I am selecting the fields from a table and i want to check one of the fields whether it is 0 or 1. If it is 0, i want to print something and if it is 1, i want to print some html.
Here is the subroutine.
sub getoverhead {
$loc = $query->param('locationName');
$select ="select location,conferenceRoomName,overHead,seats from ConferenceRooms where location ='$loc'";
$sybHandle = $syb->prepare($select);
my ($loc, $conf, $over) = $sybHandle->fetchrow;
while (my ($loc,$conf,$over,$seats) = $sybHandle->fetchrow ) {
if ($over ==1) #checking if the database value is 1
print <<"html";
<tr><td>$loc </td> <td>$conf</td><td>$seats</td></tr>
else {
print <<"html";
There is no overHead
It is not checking the value. It is printing both the if condition and also the else condition. Since it is in the while loop, for every record in the database, it is printing both the if and else conditions.
I want to check the database value. If it is 1, it should print the if condition or else condition only once. It is printing for every record.
Please help me


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives