SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: Dynamic Output

  1. #1
    Non-Member
    Join Date
    Feb 2005
    Posts
    737
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Dynamic Output

    Hi Guys,

    I have a table with 3 rows which interrigates an MySQL database for data:

    PHP Code:
    <table width="100%" border="0">
      <tr>
        <td width="33%"><?php echo $name?></td>
        <td width="33%"><?php echo $by?></td>
        <td width="33%">CLICK HERE LINK????</td>
      </tr>
    </table>
    Now this MySQL database can have lots of records in one table given unique id's as they are added in an admin section, so I want my php page to do two further things:

    1) Dynamically insert another 3 rows or every record there is in my MySQL database table named 'cinema_reviews'.

    2) In the last table row dynamically display the link or each particular record which reads 'click here'.

    Not sure how to do this though - anyone got any ideas?

    Ta

    Chris

  2. #2
    SitePoint Guru gavwvin's Avatar
    Join Date
    Nov 2004
    Location
    Cornwall, UK
    Posts
    686
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    <?
    $results 
    mysql_query("SELECT * FROM cinema_reviews");
    if(
    mysql_num_rows($results)>0) {
      echo 
    "<table width=\"100%\" border=\"0\">";
      while(
    $row mysql_fetch_assoc($results)) {
        
    ?>
        <tr>
          <td width="33%"><?php echo $row['name']; ?></td>
          <td width="33%"><?php echo $row['by']; ?></td>
          <td width="33%"><a href=\"page_to_go_to.php?id=<?php echo $row['id']; ?>\">Click Here</a></td>
        </tr>
        <?
      
    }
      echo 
    "</table>";
    } else {
      echo 
    "No reviews";
    }
    ?>
    page_to_go_to.php would contain some script which queried the db based on $_GET['id'] to find out about that id (btw I think you mean column when you say row, columns go accross, rows down)

  3. #3
    SitePoint Zealot
    Join Date
    Jun 2004
    Location
    Kansas City, MO
    Posts
    143
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    BTW, Chris, <td> are cells (columns), not rows. Though it was easy enough to follow because you included your code, the misuse of terms could make your question confusing. Might want to brush up on your HTML table terminology

  4. #4
    Non-Member
    Join Date
    Feb 2005
    Posts
    737
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Cheers guys - I'll stick to Layers!!!!!!!


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
  •