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
https://forums.phpfreaks.com/topic/27220-returning-results-from-a-function/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.