Jump to content

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

Link to comment
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!

Link to comment
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.