my code stock.com

Get db Results

Snippet options

Download: Download snippet as demo-snippets.php.
Copy snippet: For this you need a free my code stock.com account.
Embed code : You will find the embed code for this snippet at the end of the page, if you want to embed it into a website or a blog!

<?php
$username = "XXXX";
$password = "XXXX";
$hostname = "localhost";
$database = "XXXX";
$dbhandle = mysql_connect($hostname, $username, $password)
or die("Unable to connect to MySQL");
$selected = mysql_select_db($database,$dbhandle)
or die("Could not select $database");
mysql_set_charset('utf8');
$result = mysql_query("SELECT * FROM bbx_posts ORDER BY date_posted DESC LIMIT 5 ");
if(mysql_num_rows($result)) {

	$n = 0;
	while($row = mysql_fetch_array($result)) {
		
		// general information
		echo '<li><a href="news/posts/view/'.$row[postID].'">'.$row[title].'</a><span>';
	//	 echo date("m/d/y ", $row['date_posted']);
		$oDate = strtotime($row['date_posted']);
		$sDate = date("m F Y - g:i",$oDate);
		echo "<div style='direction:ltr'>";
		echo $sDate;
		echo "</div></span></li>";
		
		$n++;
	}
	
} else {

	echo "<div id='msg-alert'>We're sorry, no listings could be found that match your query.</div>";

}
?>

Create a free my code stock.com account now.

my code stok.com is a free service, which allows you to save and manage code snippes of any kind and programming language. We provide many advantages for your daily work with code-snippets, also for your teamwork. Give it a try!

Find out more and register now

You can customize the height of iFrame-Codes as needed! You can find more infos in our API Reference for iframe Embeds.