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

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

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

 



datlaravi
Deleted

Jun 21, 2000, 11:20 AM

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

Hi,
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);
$sybHandle->execute();
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>
</table>
html
}
else {
print <<"html";
There is no overHead
html
}
}
$sybHandle->finish();
exit;
}
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
Thanks

 
 


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

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