SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot
    Join Date
    May 2005
    Posts
    117
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy need help with complicated query

    i want to get some values from other tables so that i can create and insert , the code has some explenations,
    the code shoud be run if the value that is give thrue a from is correct
    I can't seem to get it working... please help me !!!!!!!!

    PHP Code:
    if($kamptype=="jongste")
        {        
            
    //get the id where the 'kamp'= current year and the type is 'jongste'
            
    $year date('Y');
            
    $result mysql_query("SELECT Kampid FROM kamp WHERE Kampjaar = '$year' AND Kamptype = 'jongste'") or die(mysql_error());
            while(
    $row mysql_fetch_array($result))
                {
                      
    $kampid$row['Kampid']; // result will be used in a nother query
                
    }
                
    //get the last entered id from table kind
                
    $laastekind="SELECT Max(kind.Kindid) FROM kind";
                
    $result1 mysql_query($laastekind);        
                if (!
    $result1
                    {
                        echo 
    "Fout in de input 1";
                    }
                    
                
    $laatsteevaluatie="SELECT Max(kindevaluatie.KindEvaluatieid) FROM kindevaluatie";
                
    $result2 mysql_query($laatsteevaluatie);        
                if (!
    $result2
                    {
                        echo 
    "Fout in de input 1";
                    }
                
                while(
    $row1=mysql_fetch_assoc($result1) || $row2=mysql_fetch_assoc($result2))
                    {
                        
    $kampid$row['Kampid']; //the id of the kamp is set
                        
    $laastekind=$row1['Max(kind.Kindid)']; // the max id of the table kind is set
                        
    $kindevaluatie=$row1['Max(kindevaluatie.KindEvaluatieid)']; // the max id of table evalutie is set
                        
                        // now that all the variables are in place, this inser should take place
                        
    $sql2="INSERT INTO kind_gaatmee_kamp (Kind_Kindid,Kamp_Kampid,KindEvaluatie_KindEvaluatieid) VALUES ('$laastekind','$kampid','$kindevaluatie')";
                        
    $result3 mysql_query($sql2);        
                        if (!
    $result3
                        {
                            echo 
    "Fout in de input 1";
                        }
                    }
        } 

  2. #2
    SitePoint Evangelist hexburner's Avatar
    Join Date
    Jan 2007
    Location
    Belgium
    Posts
    591
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi baddawg,

    I don't really understand what you're trying to do here.
    I understand you want to insert a child that goes to a specific camp into a table that contains all children that go to that specific camp, right?

    A little more information about what you want to achieve would be great. ;o)

    Grtz,
    Vince
    FOR SALE: 1 set of morals, never used, will sell cheap

  3. #3
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,500
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    And some more info about exactly isn't working would be nice too.

  4. #4
    SitePoint Zealot
    Join Date
    May 2005
    Posts
    117
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I understand you want to insert a child that goes to a specific camp into a table that contains all children that go to that specific camp, right?
    I have 4 tables ( kind, kindgaatmee(koppel tabel tussen kind en kamp), kamp, kindevaluatie)
    well i allready insert the basic information of the child , what i want now is that the child is linked to the specific kamp in the current year (dit is een koppel tabel)
    after entering the kind in the database i need to get it's uniek id which then i can use in the query. (max[kind.kindid]
    i also need the kamp id that is "jongste" for current year.
    i also need the evaluation max id of evaluatie that i made before jumping to this script

    these values i use to link kind to kamp in the table kindgaatmee

    i hope i have explained myself a bit more


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
  •