SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast Yonko's Avatar
    Join Date
    Jun 2001
    Location
    Panama
    Posts
    79
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Please help me, I'm sure you can solve this

    I have a news updating/displaying system built with php and mysql. In my front page I display a list of each news title using a query. When someone clicks one of the titles it is taken to a results page (there the body of the article and the title appear), my client just changed his mind (damn him!) and wants each article to appear in its own page. How can I do that? Maybe using SSI? Wrappin' up, I need a new page generate for each article when the user clicks the title. Please help!

  2. #2
    imagine no limitations exbabylon's Avatar
    Join Date
    Dec 2000
    Location
    Idaho, USA
    Posts
    452
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, it's really quite simple if you designed a proper database structure.

    have your urls on the home page look something like this:

    http://www.domain.com/new_file.php?id=3

    Then new_file.php would look like this:

    PHP Code:
    include("header.inc");
    if(!isset(
    $id)){
        echo(
    "No Article Selected");
    }else{
        
    $sql "SELECT * FROM tablename WHERE id='$id'";
        if(!
    $results mysql_query($sql)){
            echo(
    "No Article With That ID");
        }else{
            while(
    $row mysql_fetch_array($results)){
                
    extract($row);
                echo(
    "$title<br>By $author On $date<p>$article");
            }
        }
    }
    include(
    "footer.inc"); 
    The homepage might look like this:

    PHP Code:
    $sql "SELECT title, id FROM tablename ORDER BY date DESC LIMIT 10";
    $result mysql_query($sql);
    while(
    $row mysql_fetch_array($results){
         
    extract($row);
         echo(
    "<a href=new_file.php?id=$id>$title</a><br>");

    Blamestorming: Sitting around in a group discussing why a deadline was missed or a project failed and who was responsible.

    Exbabylon- Professional Internet Services


Bookmarks

Posting Permissions

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