SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Jan 2003
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help get bit of html and php code to work

    I cannot get these bit of code to work can anyone help tell me whats wrong?
    **** HTML front page*****

    <html>

    <head>
    <title> Venues</title>
    </head>

    <body>
    <table rules=all>

    <thead>
    <tr><th>date</th><th>venue</th><th>information</th>
    </thead>

    <tbody>
    <tr>
    <td>April 6</td><td>Melbourne</td><td> <a href="venues_info.php?venue = 1"> Austrialia </a> </td>
    </tr>
    </tbody>
    </table>
    </body>

    </html>

    ******** php for description*********
    <html>
    <head>
    <title>Venue's Description</title>
    </head>
    <body>

    <?php
    $venue = $_GET['venue'];
    if(is_numeric($venue))
    {

    $conn = mysql_connect("localhost", "user", "password")
    or die("Could not connect");

    mysql_select_db("database")
    or die("Database not found");

    $sql = "select venues_name, venues_description from venues where venues_id = $venue";
    $result = mysql_query($sql, $conn);

    if(!$result)
    {
    echo" <p> No information found for venue ID '$venue' </p>";
    }
    else{
    $row = mysql_fetch_object($result);
    echo" <h4> $row -> venues_name </h4> ";
    echo" <p> $row -> venues_description </p>";
    }}
    else {
    echo"<p> Invalid venue ID format </p>";
    }
    ?>
    </body>
    </html>

  2. #2
    SitePoint Wizard
    Join Date
    Oct 2001
    Posts
    2,686
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi, again.

    You can't have any spaces in the url in this part of the code:
    Code:
    <a href="venues_info.php?venue=1"> Austrialia </a>
    And for processing this in venues_info.php I thought I gave an answer over here.

    Anyway here is the same code example
    PHP Code:
    // venues_info.php
    $venue $_GET['venue'];

    if(
    is_numeric($venue)) {
        
    $conn mysql_connect("localhost""user""password") or die("Could not connect");
        
    mysql_select_db("databaseName") or die("Database not found");

        
    $sql "SELECT venues_name, venues_description
                FROM venues
                WHERE venues_id = 
    $venue";
        
    $result mysql_query($sql$conn);
        if(!
    $result){
            echo
    " <p> No information found for venue ID '$venueId' </p>";

        } else{
            
    $row mysql_fetch_array($result);
            echo 
    "<h4>" $row['venues_name'] . "</h4>";
            echo 
    "<p>" $row['venues_description'] . "</p>";
        }

    } else {
        echo
    "<p> Invalid venue ID format </p>"

    Hope this helps

    -Helge

  3. #3
    SitePoint Guru
    Join Date
    Feb 2002
    Location
    NZ
    Posts
    620
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Could be mistaken but it appears you have </tr> missing in here:

    Code:
    <thead>
    <tr><th>date</th><th>venue</th><th>information</th>
    </thead>


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
  •