Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.