SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict
    Join Date
    Jun 2007
    Location
    Plymouth uk
    Posts
    313
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question change display format

    i use this code to display info
    displays 1 line under another i would like to be able to change this to say 2 fields side by side without using tables
    this is the code i use at the moment

    // Output

    PHP Code:
    Echo "<b>ID:</b> ".$info['id'] . " <br>";
    Echo 
    "<b>Name:</b> ".$info['name'] . " <br>";
    Echo 
    "<b>State:</b> ".$info['state'] . " <br>";
    Echo 
    "<b>Type:</b> ".$info['type'] . " <br>";
    Echo 
    "<b>Email:</b> ".$info['email'] . " <br>";
    Echo 
    "<b>Date:</b> ".$info['date'] . " <br>";
    Echo 
    "<b>Area:</b> ".$info['area'] . " <br>";
    Echo 
    "<b>Details:</b> ".$info['details'] . " <br>";
    Echo 
    "<b>Photo:</b> ".$info['pname'] . " <br>";
    Echo 
    '<a href="update.php?id='.$info['id'].'">Update</a>';
    Echo 
    '<hr />'
    an old man of 60 trying to keep up with the youngsters he he
    http://lostpetsplymouth.net16.net

  2. #2
    SitePoint Member
    Join Date
    Mar 2008
    Location
    Norway
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you want columns the best way is using tables, but you can also achieve it with for example floating div tags.

    Code:
    <div style="width:400px;line-height:20px;">
    <div style="float:left;width:200px;">Column1</div>
    <div style="float:left;width:200px;">Column2</div>
    </div>
    This is more of an HTML issue than PHP though

  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)
    Why don't you want to use tables?

    That's what they're there for...
    PHP Code:
    <?php
    $output 
    = array();
    while(
    $info mysql_fetch_assoc($result)){
        foreach(
    $info as $key=>$value){
            if(!isset(
    $output[$key])){
                
    $output[$key] = array();
            }
            
    $output[$key][] = $value;
        }
    }
    echo 
    '<table border="1">';
    foreach(
    $output as $name=>$row){
        echo 
    '<tr>';
            
    printf('<th>%s</th>'$name);
            foreach(
    $row as $cell){
                
    printf('<td>%s</td>'$cell);
            }
        echo  
    '</tr>';
    }
    echo 
    '</table>';
    ?>
    Last edited by Jake Arkinstall; Mar 28, 2008 at 08:57. Reason: should have been mysql_fetch_assoc, so you don't get the row ID too... Oh, and added a border to the table to separate it
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  4. #4
    SitePoint Addict
    Join Date
    Jun 2007
    Location
    Plymouth uk
    Posts
    313
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thanks

    thanks to all have now sorted it
    cheers
    Doug
    an old man of 60 trying to keep up with the youngsters he he
    http://lostpetsplymouth.net16.net


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
  •