SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    Feb 2011
    Posts
    101
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Loading data from DB into table

    Hello, I've been sitting trying to load data from a database into a table, it's working but I just think the code is cluttering.. Is there a shorter way to do it?

    My code is following:

    PHP Code:
    <?php
    include('Dataconnection.php');

    $connect mysql_connect($host,$username,$password) or die('<p class="error">Unable to connect to the database server at this time.</p>');

    mysql_select_db($database,$connect) or die('<p class="error">Unable to connect to the database at this time.</p>');

    $query "SELECT MemberID, FirstName, MiddleName, LastName FROM Golf_Member;";

    $result = @mysql_query("$query") or die('<p class="error">There was an unexpected error grabbing shouts from the database.</p>');
    ?>
    <html>
    <body>
    <table width="400" border="1">
        <tr>
            <th>Member ID</th>
            <th>First Name</th>
            <th>Middle Name</th>
            <th>Last Name</th>
        </tr>
        <?

    while ($row mysql_fetch_assoc($result)) {
            
                
    $MemberID stripslashes($row['MemberID']);
                
    $FirstName stripslashes($row['FirstName']);
                
    $MiddleName stripslashes($row['MiddleName']);
                   
    $LastName stripslashes($row['LastName']);
                
                
    $repeater '<td>'.$MemberID.'</td><td>'.$FirstName.'</td><td>'.$MiddleName.'</td><td>'.$LastName.'</td>';
                
                echo(
    '<tr>'.$repeater.'</tr>');
    }
    ?>
    </table>
    </body>
    </html>

  2. #2
    SitePoint Member
    Join Date
    Mar 2011
    Location
    NY
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Use ORM

  3. #3
    SitePoint Zealot
    Join Date
    Feb 2011
    Posts
    101
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by RobertJohnson View Post
    Use ORM
    can you maybe specify it a little more? - I'm not the most pro guy.


Tags for this Thread

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
  •