# Miscellaneous > Database Programming >  PHP links to MySql database

## bygmony

I have made a MySql database in which I will input news stories via a web form. Those stories will then display on a web page using php. I can get the stories to diplay but when I display the story titles and try to link each title to its story I only get the first story in the database to display. I am using Dreamweaver MX. I have being able to get this to work using JSP but not with PHP. Dreamweaver give you a go to page option with JSP but not with PHP. This go to page option allows you to link to each row of data and display it.

Thanks for the help on this and the formating issue I had.

----------


## greenman

I don't know about Dreamweaver, but it's really easy to do it in PHP - I find using extra stuff on top of that just complicates matters when you want to make changes. But then I still use a text editor to code html. Anyway, here's a simplified code snippet:

/* Performing SQL query */
    $query = "SELECT * FROM my_table";
    $result = mysql_query($query) or die("Query failed");

    /* Printing results in HTML */
    print "<table>\n";
    while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
        print "\t<tr>\n";
        foreach ($line as $col_value) {
            print "\t\t<td>$col_value</td>\n";
        }
        print "\t</tr>\n";
    }
    print "</table>\n";

You may also want to read this article

----------


## budu

I am currently trying to find scripts that would display articles on my website using php and mysql database, I want to get the database to display the articles titles and a description of each title and then link each title to its article. Can you pls help!

----------


## greenman

Lots of scripts available - you can look on the PHP and MySQL sites for links to scripts.

----------


## bygmony

I think I can help with that. I have just completed making a website that displays new articles that have been entered in a MySql DB. I am at home right today (sick kids) but when I get to work tomorrow I'll be glad to hook up with you and share my code. I used Dreamweaver MX and some plain ole' fashing hand coding to make it happen.

I am on the east coast and I get to work around 8:30 am. Shoot me an email at bygmony@hotmail.com tomorrow when your ready to talk.

----------

