ok been trying to figure this out for a little while now. How do you generate different pages for different items in your database, so ID=0234 for one item etc etc. cheers.

    You run a query that gets all the data for that id then display it on the page.

      quick question would i use an include line to return the $id in the url?

        quick question would i use an include line to return the $id in the url?

        Im not sure what you meen there, sorry.

        Maybe a quick example.

        article.php

        <?php
        
          if (isset($_GET['id'])) {
            // connect to database
            $sql = "SELECT title, article FROM articles WHERE id = '{$_GET['id']}';";
            if ($result = mysql_query($sql)) {
              $row = mysql_fecth_assoc($result);
              echo "<h1>{$row['title']}</h1>";
              echo "<p>{$row['article']}</p>";
            } else {
              echo "no article found with id number {$_GET['id']}";
            }
          }
        
        ?>
        

        Now, if you go to http://yourserver/article.php?id=4 this page would display the article with an id of 4 stored in the database.

        Hope that helps.

          Write a Reply...