Results 1 to 2 of 2
  1. #1
    4 Star Lounger
    Join Date
    Feb 2008
    Location
    United Kingdom
    Posts
    490
    Thanks
    0
    Thanked 0 Times in 0 Posts

    PHP result in fields

    I am trying to modify this code from being rows to fields, but so far not working. It still produces multiple rows when at present there are only 3. Its duplicating the data? Thanks

    echo "$num_fieldsn";


    if (mysql_num_fields($result) > 0){
    echo "<table border="1">rn";
    while ($fields = mysql_fetch_assoc($result)){
    foreach ($fields as $fields=>$value){
    //start the row
    echo "t<tr>rn";
    //start the actual data
    echo "tt<td>$fields</td><td><input type="text" name="$fields" value="$value" /></td></tr>rn";
    echo "t</tr>rn";
    }
    } //end the while loop
    echo "</table>rn";
    } else {
    echo "No Data found";
    }

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: PHP result in fields

    <hr>I am trying to modify this code from being rows to fields<hr>
    Not sure what you mean by "fields." Do you mean HTML textboxes (<input type="text">)?

    What does the working code look like? I think there is a problem in your foreach statement, since you have <code>fields$</code> twice. This page might help: PHP: foreach - Manual @ php.net.

Posting Permissions

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