SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Apr 2007
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    how to get it to do 5 per row

    i cant figure out how to make it do ie.. 5 per row any one able to help?




    echo "<table>";
    while ($x < count($var1)){
    if($x < 5){
    echo "<td><input type='radio' name='drink' value=$var1[$x] /> $var1[$x]</td></tr>";
    }
    $x++ ;
    }

  2. #2
    SitePoint Wizard wheeler's Avatar
    Join Date
    Mar 2006
    Location
    Gold Coast, Australia
    Posts
    1,369
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You have a range of problems, firstly, add your php in [ php ][ /php ] tags without the extra spaces, it makes it easier to read.

    "for" is more suited to what you are doing.

    And also, you missed the first <tr> tag.

    PHP Code:
    $a 10;

    echo 
    "<table>\r\n"// start table, add new line for code readability

    for ($i=0;$i $a$i++)
    {
        echo 
    "<tr><td>$i</td></tr>\r\n";
    }

    echo 
    "</table>\r\n"
    Off Topic:

    500 posts woohoo now I can do some work!
    Studiotime - Time Management for Web Developers
    to-do's, messages, invoicing, reporting - 30 day free trial!
    Thomas Multimedia Web Development

  3. #3
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Hm, I think valduare wants to output 5 values on each row?

    PHP Code:
    echo '<table><tr>';
    foreach(
    $var1 as $i=>$v){
      echo 
    "<td><input type='radio' name='drink' value=\"$v\" />$v</td>";
      if((
    $i+1)%5==0) echo '</tr><tr>';
    }
    echo 
    '</tr></table>'
    Off Topic:


    wheeler, only 500? that's slooow! Congrats.
    Saul


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
  •