seran128 Posted November 14, 2006 Share Posted November 14, 2006 I have a function the goes out and gets heading for a news category likeTodays NewsYesterdays NewsOnce I get those categories I then want to get the news under themLikeTodays NewsNews Story 1News Story 2News Story 3Yesterdays NewsNews Story 1News Story 2News Story 3ok 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 pageMy 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 More sharing options...
trq Posted November 14, 2006 Share Posted November 14, 2006 What is your question? Link to comment https://forums.phpfreaks.com/topic/27220-returning-results-from-a-function/#findComment-124453 Share on other sites More sharing options...
seran128 Posted November 14, 2006 Author Share Posted November 14, 2006 The above code does not place the results of both queries in the $getcategorynews .= tag so when I return the $getcategorynews from the function it does not work. THe SQL works but not the return Link to comment https://forums.phpfreaks.com/topic/27220-returning-results-from-a-function/#findComment-124463 Share on other sites More sharing options...
haaglin Posted November 14, 2006 Share Posted November 14, 2006 You need to add $getcategorynews .= in your second while statement. Link to comment https://forums.phpfreaks.com/topic/27220-returning-results-from-a-function/#findComment-124470 Share on other sites More sharing options...
seran128 Posted November 14, 2006 Author Share Posted November 14, 2006 Thanks! Link to comment https://forums.phpfreaks.com/topic/27220-returning-results-from-a-function/#findComment-124504 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.