SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: Help !

  1. #1
    SitePoint Zealot
    Join Date
    Apr 2003
    Location
    Denmark
    Posts
    127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Help !

    How do i get 3 different values from one mysql record into 3 different columns <td></td><td></td><td></td> so it will be listed nicely and seperated.

    i would like it to be listed like this as in a ordinary table. Can i do that from one record.

    <tr><td>New York</td><td>London</td><td>Copenhagen</td></tr>
    <tr><td>if ($a==1) { echo ""; }</td><td>if ($a==2) { echo ""; }</td><td>if ($a==3) { echo ""; }</td></tr>


    PHP Code:

    while ($cat mysql_fetch_array($cats)) {

    $sta = array($cat['sta']);

    foreach ( 
    $sta as $a ) {

    if ( 
    $a == ) {

    echo(
    "New York: <input type='checkbox' name='cats[]' value='$cid' />&nbsp;$cname<br />\n"); 

    }

    if ( 
    $a == ) {

    echo(
    "London: <input type='checkbox' name='cats[]' value='$cid' />&nbsp;$cname<br />\n"); 

    }


    if ( 
    $a == ) {

    echo(
    "Copenhagen: <input type='checkbox' name='cats[]' value='$cid' />&nbsp;$cname<br />\n"); 

    }


    Last edited by abo2512; Jun 28, 2003 at 08:02.

  2. #2
    SitePoint Evangelist
    Join Date
    Apr 2003
    Location
    lisboa
    Posts
    423
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    the code i posted next door http://www.sitepointforums.com/showt...hreadid=115830 was suposed to do so...

  3. #3
    SitePoint Zealot
    Join Date
    Apr 2003
    Location
    Denmark
    Posts
    127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    ?

    That dosnīt help me with my problem ?

  4. #4
    if($awake){code();} PHP John's Avatar
    Join Date
    Jul 2002
    Location
    Along the Wasatch Fault line.
    Posts
    1,771
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What are your field names?

    Let's say your fields are "fldOne, fldTwo, and fldThree":
    PHP Code:
    while($cat mysql_fetch_array($cats))
    {
      echo 
    '<input type="checkbox" name="cats[]" value="'.$cat['fldTwo'].'" />&nbsp;'.$cat['fldThree'].'&nbsp;';
      
    $rowCount++;
      if(
    $rowCount == 3)
      {
        echo 
    '<br />';
        
    $rowCount 0;
      }

    This will take each row of retrieved info and display it in three columns.
    John


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
  •