SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Hybrid View

  1. #1
    SitePoint Guru Richi's Avatar
    Join Date
    Jul 2001
    Location
    Hu,Bp.
    Posts
    842
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    html select, and inserting to var. ?!

    Hi all again !

    now i just wanna know this, i have html select which will sort the sub_cat, sub_cat_id, and catagory :
    PHP Code:

    $sql_cat
    ="select * from subcat";
    $result_cat=@mysql_query($sql_cat,$db);

    echo 
    "<select name=\"newsub_cat\">";

              while(
    $mycat=@mysql_fetch_array($result_cat))
        {

    $sub_cat=$mycat["sub_cat"];
    $sub_cat_id=$mycat["sub_cat_id"];
    $catagory=$mycat["catagory"];

      echo
    "<option value=\"$sub_cat\">:: $catagory  :::  $sub_cat :::  $sub_cat_id ::</option>";

    }


    echo
    "</select>";
    ?> 
    with this way i can insert just the sub_cat, i need to insert the catagory also into another table which include catagory and sub_cat field ?

    i was trying with this :

    PHP Code:
    $query mysql_query("Select catagory from subcat where newsub_cat='$sub_cat'",$db);
    list(
    $sub_cat_id$sub_cat$catagory) = mysql_fetch_row($query);

    echo 
    "[$catagory$newsub_cat";
    $newcat=$catagory
    but didn`t work !
    Last edited by Richi; Aug 13, 2001 at 04:42.

  2. #2
    The Hiding One lynlimz's Avatar
    Join Date
    Jul 2000
    Location
    Singapore
    Posts
    2,103
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    use UPDATE...

    From the mySQL Documentation
    http://www.mysql.com/doc/U/P/UPDATE.html
    "Imagination is more important than knowledge. Knowledge is limited. Imagination encircles the world."
    -- Albert Einstein

  3. #3
    SitePoint Guru Richi's Avatar
    Join Date
    Jul 2001
    Location
    Hu,Bp.
    Posts
    842
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok, i know that, but here i have var.,from this var. i need to update or to insert to db. 2 var. !

    when i select from the html select, ill choose the sub_cat, which i can insterted to the db. but how can i insert also this sub_cat main catagory also into the db. ?

    Code:
    Field Type Attributes Null Default Extra Action 
    sub_cat_id  int(7)    No    auto_increment  Change Drop Primary Index Unique 
    sub_cat  varchar(30)    Yes      Change Drop Primary Index Unique 
    catagory  varchar(30)    No
    see, when i select the sub_cat also there are catagory !

  4. #4
    SitePoint Guru Richi's Avatar
    Join Date
    Jul 2001
    Location
    Hu,Bp.
    Posts
    842
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    done with this code :
    PHP Code:
    $query mysql_query("Select * from subcat where sub_cat='$newsub_cat'");
        
    $count mysql_num_rows($query);

        
    $h mysql_fetch_array($query);
    echo 
    "[".$h[catagory]."]";
    $catagory1$h[catagory]; 


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
  •