Return to Snippet

Revision: 44266
at April 8, 2011 21:04 by JonnySnip3r


Initial Code
<?php
// Connect to the server::
mysql_connect('localhost','jonno','password')
	or die('Sorry, an error occurred when connecting to the server.');

// Select the database::
mysql_select_db('carl_forum')
	or die ('Sorry, an error occurred when select the database.');
	
	// Set uo our sql statement::
	$sql = "SELECT * FROM posts ORDER BY post_id DESC";
?>

<html>
	<head>
		<title>Carl's Forum</title>
	</head>

	<body>
		<?php
		
		$query = mysql_query($sql);
		while($row = mysql_fetch_array($query))
		{
			// Place the title_post inside a header 1 tag, so it looks nice and big::
			echo '<h1>' . $row['post_title'] . '</h1>';
			
			// Now place the post_body inside some paragraph tags so they look nice::
			echo '<p>' . $row['post_body'] . '</p>';
		}
		
		?>
	</body>
</html>

Initial URL

                                

Initial Description
Just a simple database script.

Initial Title
Simple database script

Initial Tags
database, simple

Initial Language
PHP