Jump to content

Insert Text from MySQL into an object


PHPLeader

Recommended Posts

I have a MySQL Database set up. I have tested it, and I have been able to access my database, table and row successfully. I have a banner at the top of my page, which is a DIV. Its ID is "Banner". I would like it to insert the result into the DIV. The code I have echo's the result, but I want it to insert the result into the DIV. Here is my code:

<?php
// Make a MySQL Connection
mysql_connect("localhost", "*****", "*****") or die(mysql_error()); // Yes its stared out, but the real code has got correct info
mysql_select_db("mastermovies_co") or die(mysql_error());


// Retrieve all the data from the "example" table
$result = mysql_query("SELECT * FROM note")
or die(mysql_error());  


// store the record of the "example" table into $row
$row = mysql_fetch_array( $result );
// Print out the contents of the entry 


echo "".$row['text']
?>

 

 

What would I change the echo to?

 

 

And also, where do I put the PHP code? Head? Body?

 

 

Im quite new to PHP, as I prefer Javascript, but in this case I had to learn some PHP and MySQL.

Link to comment
https://forums.phpfreaks.com/topic/244766-insert-text-from-mysql-into-an-object/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.