Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: Php columns

  1. #1
    New to the CF scene
    Join Date
    Mar 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Php columns

    HELP!!! I am trying to have my data displayed in 4 colums wide on my page, can anyone help! Here is the code:

    <?php

    //connect include
    require ("connect.php");

    //extract data
    $extract = mysql_query ("SELECT * FROM people ORDER BY id ASC");
    $numrows = mysql_num_rows ($extract);

    while ($row = mysql_fetch_assoc ($extract))
    {

    $id = $row['id'];
    $firstname = $row['firstname'];
    $lastname = $row['lastname'];
    $dob = $row['dob'];
    $gender = $row['gender'];

    if ($gender=="F")
    $gender = "Female";
    else
    $gender = "Male";


    echo "$firstname $lastname<br> was born on $dob<br> and is $gender<br /><br />";


    }


    ?>

  • #2
    New Coder
    Join Date
    Mar 2010
    Location
    Australia
    Posts
    93
    Thanks
    38
    Thanked 0 Times in 0 Posts
    the best way is to use tables:
    Code:
    while($row = mysql_fetch_array($result))
      {
    	
    	  echo "<tr>";
                       echo "<td>" . $firstname. "</td>";
                       echo "<td>" . $lastname. "</td>";
    		   echo "<td>" . "was born on". "</td>";
    		   echo "<td>" . $dob. "</td>";
                       echo "<td>" . $gender. "</td>";
          echo   "</tr>";
    	 
      }


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •