Jump to content

Returning results from a Function


seran128

Recommended Posts

I have a function the goes out and gets heading for a news category like

Todays News

Yesterdays News

Once I get those categories I then want to get the news under them

Like


Todays News

News Story 1
News Story 2
News Story 3

Yesterdays News

News Story 1
News Story 2
News Story 3

ok In my function I want to do all this and then return the value back to my page in one return statement so I can position the values on my page

My Function


[code]function getcategorynews($inId){
global $connection;
$sql=mysql_query("select * from webcontent_news_category ORDER BY RAND() LIMIT $inId")or die(mysql_error());
while($row=mysql_fetch_array($sql)) {
$getcategorynews .= "<table width='200' border='0'>
    <tr>
      <td>" . stripslashes($row['category_description']) . "</td>
</tr>
  </table>";
  $sqls = mysql_query("SELECT `webcontent_news`.`short_description`
FROM
`webcontent_category_x_news`
Inner Join `webcontent_news` ON `webcontent_news`.`NewsID` = `webcontent_category_x_news`.`NewsID`
WHERE
`webcontent_category_x_news`.`CategoryID` =  '$row[CategoryID]'") or die(mysql_error());
while($rows=mysql_fetch_array($sqls)) {
"<table width='200' border='0'>
<tr>
      <td>" . stripslashes($row['short_description']) . "</td>
</tr>
  </table>";
}



}
return $getcategorynews;
}[/code]
Link to comment
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.