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 Quote Link to comment 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] Quote Link to comment Share on other sites More sharing options...
seran128 Posted November 10, 2006 Author Share Posted November 10, 2006 Works great!!!!!!!! thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.