I have a little knowledge of SQL, however very very little of php,

I am wanting to display information from a database in a small area of a php page, I have already created the area on the page etc and "hard coded" the info in there for now, however I am needing it to read it from a database ideally, the information is already in the db, as it is used elswhere dynamically.

in phpmyadmin i can run:

SELECT doc_content
FROM `store_cart_docs`
WHERE `doc_id` =3

and this returns the field i need displaying.

Any help would be appreciated, many thanks in advance

fill in the info below and then put this where you want the content displayed.

i put some basic html stuff in there to show you what you can do. change this accordingly.

<?php

//Database Info
$host = 'localhost'; //usually localhost, but depends on how the server is set up
$user = ''; //Database user name
$pass = ''; //Database password
$db   = ''; //Database Name

$con = mysql_connect($host,$user,$pass) or die('Error: Couldn\'t connect to database');
mysql_select_db($db,$con) or die('Error: Couldn\'t select database);

$sql   = "SELECT `doc_content` FROM `store_cart_docs` WHERE `doc_id` = 3";
$query = mysql_query($sql,$con);
$total = mysql_num_rows($query);
if ($total > 0) {
	while (list($content) = mysql_fetch_row($query)) {
		echo "<div align=\"center\">{$content}</div>";
	}
}

mysql_close($con);

?>
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.