The code below should produce my homepage but it doesnt display the stuff from the database, the page works by setting the content as the $content variable and then replacing it in the template file to make the page, any ideas?

$content = '<div id="leftindex">';  

if ($db_found) {



$SQL = "SELECT * FROM articles WHERE show = 'yes'";
$result = mysql_query($SQL);
while ($db_field = mysql_fetch_assoc($result)) {
$content.='<div id=\"par\"><h2>';
$content.= $db_field['title'];
$content.='</h2><p>';
$content.= $db_field['story'];
$content.='</p></div>';
}


mysql_close($db_handle);

}
else {
print "Database NOT Found ";
mysql_close($db_handle);
}

$content.='</div>

<div id="rightindex"> 

<div id="par"><h2>Follow us...</h2>
   	<p><table><tr><td><img src="/template/images/fblogo.png"></td><td><a href="" class="general">Facebook</a></td></tr>
   	<tr><td><img src="/template/images/rsslogo.png"></td><td><a href="" class="general">RSS</a></td></tr></table>
   	</p>
 
</div>

<div id="par"><h2>Weather</h2>
<iframe src="/template/weather.html" border="0" height="190px" width="248px" scrolling="no" style="border:0px;"></iframe>
 
</div>



</div>';
$template = file_get_contents('template/template.html');

function makepage(){
	global $content, $template;

	$template = str_replace('@FCC_BODY@',$content,$template);
	die($template);
	
}





makepage();

1) Check whether your template file contains @FCC_BODY@ text or not
2) open you database (may be phpmyadmin) and execute your query, whether it gives result or not. "SELECT * FROM articles WHERE show = 'yes'"

Make sure you have set mysql connection "db_handle", in the begining of the code.
and make use of it for getting the result
$result = mysql_query($SQL,$db_handle);

thank you, i have sorted it, it was something to do with my syntax, ran it through sql and found out the correct syntax.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.