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

9 Years
Discussion Span
Last Post by somedude3488

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.


//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>";


This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.