Jump to content

Recommended Posts

<?
function get_shoutz($user,$start,$limit)
{
if($start=="") { $start="0"; }
if($limit=="") { $limit="5"; }
$query = "SELECT * FROM shoutz where owner='$user' limit $start,$limit"; 
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($result)){$count++;
$poster = $row["poster"];
$dst = $row["date"];
$shout = $row["shout"];
$whole_thing "<b>".$poster."</b><br>".$dst."<br>"."<div class='shout'>".$shout."</div>";
}
}
get_shoutz("1","","");
?>

Umm what it does is fetches rows from a table called shoutz depending on the start and limit variables.

So in this case it would use the defauly 0 for start and 5 for limit.

anyways

the rows are being fetched in a loop what I want to do is combine all the 5 rows fetched in to one variable like $shotbox and than use return $shoutbox; at the end of the function so where ever i put get_shouts("1","",""); it will show the whole thing.

 

Sorry if i'm confusing. not sure how to say it.

 

Link to comment
https://forums.phpfreaks.com/topic/49038-php-function-with-loop-query/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.