problem related to the fucntion mysql_num_rows($qResult) ...
Posted: Thu Aug 24, 2006 11:10 pm
feyd | Please use
code snippet - B
in the PHP code block if i call code snippet - B before snippet - A it doesnt return the user's "name" from the
"printMemberName()" and also it doesnt print all the rows from
"printMembers()".
Why is that? I have used the reset() functions to reset the array pointer of the $qResult to the base element but it doesnt work gives an error. How do i call the code snippet - B before code snippet - A to print the users details as, user's name displays seperate and it follows the complete details of the user in a form of a table!
i hope my question is clear
cheers
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
when i use
"$rows = mysql_num_rows($qResult);"
where "mysql_num_rows($qResult)" is a built in PHP function.
$rows containts all the rows effected by passed $qResult.
assume the $rows containts rows of a table which has headings as
"name", "address", "phone".
if we try to acess them via a loop we write it as :
code snippet - ACode: Select all
function printMembers($qResult)
{
while ($arow = mysql_num_rows($qResult))
{
$temp = "<table><tr><td>". $arow["name"]."</td></tr>";
$temp .= "<tr><td>".$arow["address"]."</td></tr>";
$temp .= "<tr><td>".$arow["phone"]."</td></tr></table>";
print $temp; //this will print one row at time
}
}code snippet - B
Code: Select all
function printMemberName($qResult)
{
$userNameStore = mysql_num_rows($qResult) $userNameDisplay = $userNameStore["name"];
return $userNameDisplay; //should return user's name
}"printMemberName()" and also it doesnt print all the rows from
"printMembers()".
Why is that? I have used the reset() functions to reset the array pointer of the $qResult to the base element but it doesnt work gives an error. How do i call the code snippet - B before code snippet - A to print the users details as, user's name displays seperate and it follows the complete details of the user in a form of a table!
i hope my question is clear
cheers
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]