$query="select * from emp where ename='$ename' and empno='$empno'";
print "<br>".$query;
$result=mysql_query($query);
print "<br>".$result."<br>";
//print if($result);
if($result)
{
print_r(mysql_fetch_array($result));
while($row=mysql_fetch_array($result))
{
echo "This is from Stalinreddy";
echo "<br>".$row['ename'];
}
}
in the above code with in the if loop only one statement (i.e if we write print_r() first then it will excuted other wise whil)either print_r() or while loop is excuted ,(both are not excuted),can any body give me a explanation
some clarification with Databa communication using php,mysql
Moderator: General Moderators
-
harishreddy
- Forum Newbie
- Posts: 5
- Joined: Sun Mar 08, 2009 12:22 am
Re: some clarification with Databa communication using php,mysql
As the manual clearly states:
Try this (also from the manual):
Edit: No it's not that because you are calling mysql_fetch_array twice.Remember that print_r() will move the array pointer to the end. Use reset() to bring it back to beginning.
Try this (also from the manual):
array mysql_fetch_array ( resource $result [, int $result_type] )
Returns an array that corresponds to the fetched row and moves the internal data pointer ahead.