seran128 Posted November 10, 2006 Share Posted November 10, 2006 I have two pages the first page has index.php[code]<?include('functions.php'); $content = getcontent();?>[/code]then later in that page I want to <? echo $content ?> so i can place the results of the function anywhere on my page.Functions.php[code]function getcontent(){ global $connection; $sql="select * from content"; $result=mysql_query($sql,$connection) or die(mysql_error()); while($row=mysql_fetch_array($result)) { ?> <table width="200" border="1"> <tr> <td><? echo stripslashes($row['content']); ?></td> </tr> <tr> <td>...................................................</td> </tr> </table> <? } return $news;}[/code] the problem is that it print the table out at the top of the page. I need to get the results of this function into a var named $news then I can echo that on the first page and controll its placement Link to comment https://forums.phpfreaks.com/topic/26845-returning-a-recordset-in-a-table/ Share on other sites More sharing options...
glenelkins Posted November 10, 2006 Share Posted November 10, 2006 you need to make $news equal the content. Then echo $content[code]while ($row = mysql_fetch_array($result)) { $news .= "<table width='200' border='1'> <tr> <td>" . stripslashes($row['content']) . "</td> </tr> <tr> <td>............................................</td> </tr> </table>";}return $news;[/code]then [code]echo ($content = getcontent());[/code] Link to comment https://forums.phpfreaks.com/topic/26845-returning-a-recordset-in-a-table/#findComment-122742 Share on other sites More sharing options...
seran128 Posted November 10, 2006 Author Share Posted November 10, 2006 Works great!!!!!!!! thanks Link to comment https://forums.phpfreaks.com/topic/26845-returning-a-recordset-in-a-table/#findComment-122743 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.