Jump to content

Archived

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

emsie

MySQL onto a web page

Recommended Posts

Hi, I'm very new to dreamweaver and MySQL, and although I have set up my database, and have it all connected down the side of Dreamweaver, I do not know how to put it in to a webpage (and can't find anywhere which tells me how to, only how to set up connections, which I've done).

 

Please can you give me a little step-by-step guide, or point me in the right direction of one.

 

I really need to know how to search fields and display them on the page.

 

Cheers in advance,

 

Emma

Share this post


Link to post
Share on other sites

think of it this way (i hope i'm not simplifying too much, but based on your question, i'm assuming no prior knowledge):

 

1. what do i want to pull from my database? (SQL query)

2. where do i want to store the results until i display them? ($result variable)

3. how do i look through my results and display them? (while loop)

 

let's pretend that you simply have a small table called 'Names' with the following info:

 

ID | Name
-----------------
1  | George
2  | Ralph
3  | Sandra 

 

First, what do i want to pull -- in this case, i just want to list all the names:

$sql = "SELECT Name FROM Names";

Next, i store the results so i can loop through them:

$results = mysql_query($sql, $conn);

Once i have the data, let's loop through and print each individual record:

while ($result = mysql_fetch_array($results)) {
   $name = $result['Name'];
   echo $name . "<br />";
}

 

this will list through all the names you have pulled from the database.

 

hope this helps get you started!

Share this post


Link to post
Share on other sites

Thank you! No prior knowledge. That has helped a lot. Going to go and fiddle with some things.

 

Thanks again.

 

Emma

Share this post


Link to post
Share on other sites

×

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.