SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: coding problem

  1. #1
    SitePoint Enthusiast
    Join Date
    Jan 2009
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    coding problem

    <?php


    Hi can anyone help with the following code as it wont compile:



    $rsQuery = "SELECT t1.Forename, t1.Surname FROM staff t1";
    $rsDetails = $db_object->query($rsQuery);
    While($rsDetails->fetchinto($rowdata)){;


    echo "<table>";
    <table border="1">;
    <tr>
    <td <?php echo $rowdata['Forename'];?></td>
    <td <?php echo $rowdata['Forename'];?></td>
    <td <?php echo $rowdata['Forename'];?></td>
    </tr>
    echo "</table>"

    }
    ?>



    Thanks very much.

  2. #2
    Web Professional
    Join Date
    Oct 2008
    Location
    London
    Posts
    862
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It won't compile because PHP code doesn't compile. It's parsed and executed on-the-fly.

    What is the error message?

    EDIT: Wrap your code in [PHP][/PHP] tags.

  3. #3
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Welcome to the forums.

    First of all there's a colon after the while(), and secondly there is HTML which you just have there which isn't being output or stored as a string - i.e. it doesn't belong there
    Some clearing up for you:
    PHP Code:
    <?php
    $rsQuery 
    'SELECT t1.Forename, t1.Surname FROM staff t1 ORDER BY Surname ASC';
    $rsDetails $db_object->query($rsQuery); 
    echo 
    '<table border="1">';
    While(
    $rsDetails->fetchinto($rowdata)){
    echo <<<ROW
            <tr>
                <td>
    {$rowdata['Surname']}</td>
                <td>
    {$rowdata['Forename']}</td>
            </tr>
    ROW;
    }
    ?>
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  4. #4
    SitePoint Enthusiast
    Join Date
    Jan 2009
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hey,

    thanks very much. thats worked really well.

    much appreciated.



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
  •