
datlaravi
Deleted
Jun 21, 2000, 11:20 AM
Post #1 of 1
(156 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
|