php code problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sanya
Forum Newbie
Posts: 1
Joined: Wed Apr 07, 2010 10:18 am

php code problem

Post by sanya »

[b]can sumbody tell me wats the problem in ma code[/b]
[b]why it is showing output s1 equals 0 everytime[/b]
<?php
require("page.inc");
$login=new page();
$login->setcontent("<p>ds</p>");
$login->display();

$pg=pg_connect('dbname=java1 user=aanchal password=aakash77');

if(!$pg)
{
echo "cannot connect to the database.";
exit;
}
$query="select status from status";
$result=pg_query($pg,$query);


if(!$result)
{
echo "cannot run query.";
exit;
}


if($result)
{
for($i=0; $i<pg_num_rows($result);$i++)

{
$row=pg_fetch_array($result,$i);
$s1=($row["status"]);
echo"$s1";
switch ($s1) {
case 0:
echo "s1 equals 0";
break;
case 1:
echo "s1equals 1";
break;
case 2:
echo "s1 equals 2";
break;
}


}


}



?>
[b]why it is showing output s1 equals 0 everytime[/b]
???????????????????????
Post Reply