Results 1 to 5 of 5

Thread: PHP links to MySql database

  1. #1
    Join Date
    Feb 2003
    Location
    VA
    Posts
    10

    Question PHP links to MySql database

    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.

  2. #2
    Join Date
    Dec 2002
    Location
    Cape Town, South Africa
    Posts
    75
    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

  3. #3
    Join Date
    Feb 2003
    Posts
    2

    Php+MySql database

    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!

  4. #4
    Join Date
    Dec 2002
    Location
    Cape Town, South Africa
    Posts
    75
    Lots of scripts available - you can look on the PHP and MySQL sites for links to scripts.

  5. #5
    Join Date
    Feb 2003
    Location
    VA
    Posts
    10

    For Budu

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •