Results 1 to 4 of 4

Thread: Show all fields except id

  1. #1
    Join Date
    Jul 2009
    Posts
    127

    Show all fields except id

    Hi
    I am trying a code in php, I have some the following code with me, please check it.
    Code:
    $fld = array();
    $sql = "SHOW fld FROM ".$acronym;
    $rsl = mysql_query($sql);
    $i = 1; // to skip the id field
    while ($rw = mysql_fetch_array($rsl)) {
        $fld[]= $rw['Field'];
    }
    $str = implode(", ", $fld);
    echo $str;
    I think this is what it should happen
    Code:
    $sql = "INSERT INTO ".$acronym." (".$str.") VALUES (".$strLine[$line].")";
    Can i exclude all the tags except the ID field which I have in the code.

  2. #2
    Join Date
    Apr 2008
    Posts
    1,948

    Re: Show all fields except id

    Hello
    To work it properly you have to add the following part of to your code.
    Code:
    if($row['Field']=="id"){
    continue;
    }
    This should come after this statement in the code.
    Code:
    while ($rw = mysql_fetch_array($rsl)) {
    I have modified your code please check it may help you.
    Code:
    $fld = array();
    $sql = "SHOW fld FROM ".$acronym;
    $rsl = mysql_query($sql);
    $i = 1; // to skip the id field
    while ($rw = mysql_fetch_array($rsl)) {
        if($rw['Field']=="id"){
            continue;
        }
        $fld[]= $rw['Field'];
    }
    $str = implode(", ", $fld);
    echo $str;

  3. #3
    Join Date
    May 2008
    Posts
    2,389

    Re: Show all fields except id

    Hi
    the above given example is a good code to demonstrate and to use. This will help you a lot, just try to understand it.
    Code:
    while ($rw = mysql_fetch_array($rsl)) {
        if($rw['Field']=="id"){
            continue;
        }
        $fld[]= $rw['Field'];
    }
    This part of the code is where you have to concentrate more. Once you understand this part if the code then the remaining is easy comings. You can just use the select statement as well and leave the id from it. I think this should not be a problem.

  4. #4
    Join Date
    Jul 2009
    Posts
    127

    Re: Show all fields except id

    Hey guys
    Thanks for your help. I have solved the problem with you support and help. I have found the appropriate solution for it. I will continue with my php code.

Similar Threads

  1. Outlook Fields Change by Themselves
    By gmatting in forum Windows Software
    Replies: 9
    Last Post: 28-07-2010, 02:39 AM
  2. Why to use set/get methods for private fields?
    By Klaty in forum Software Development
    Replies: 5
    Last Post: 05-01-2010, 12:08 PM
  3. How to add two fields in ms access?
    By lootera in forum Windows Software
    Replies: 3
    Last Post: 03-09-2009, 09:18 PM
  4. Convert UTF-8 fields
    By S_Asnodkar in forum Software Development
    Replies: 2
    Last Post: 09-05-2009, 12:02 AM
  5. Search multiple sql fields
    By Zindin in forum Software Development
    Replies: 4
    Last Post: 26-02-2009, 10:40 AM

Tags for this Thread

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
  •  
Page generated in 1,714,147,569.66259 seconds with 17 queries