Jump to content

mikosiko

Members
  • Posts

    1,327
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by mikosiko

  1. gotcha....  so.. my first answer was correct..... that is not possible to do that WITH A TRIGGER  for this reason:

     

    "A stored function or trigger cannot modify a table that is already being used (for reading or writing) by the statement that invoked the function or trigger."

  2. I feel your pain  ;)  been there done that :)

     

    here is something that could help you http://www.elearningguild.com/research/archives/index.cfm?id=130&action=viewonly  that is one of the good analysis about LMS's that I saw sometime ago.

     

    answer is complex as you know already... all depend on what functionality/standards  are you looking for... also important to consider if you want the "free" alternatives or the commercial hosted ones (they are several with good functionalities).

     

    if you want to evaluate commercial alternatives take a look to http://www.intellum.com/learning-management.html .... we have been using this one for some years now and it works very well... but as I said... is going to depend of your objectives.

     

    hope this help

     

     

  3. ok I Just read most of that article and that doesn't help me, how would I do this WITH A TRIGGER to achieve the same effect I am looking for :)

     

    Thanks for the help though much appreciated :)

     

    well... seems that you didn't read enough or you don't have a good understanding about how triggers work... which is ok.. we all started in some point :) (no offense intended)

     

    lets see...

    what you wrote was:

    DELIMITER ~
    CREATE TRIGGER updTrgr BEFORE INSERT ON tester
    FOR EACH ROW BEGIN
        UPDATE tester SET tester.order = tester.order + 1 WHERE new.order <= tester.order;
    END;~
    DELIMITER ;

     

    just look the code... and ask yourself

    - why if what I wrote is a BEFORE INSERT trigger I'm trying to UPDATE a row that is not there? (you are just inserting that row)... this doesn't make sense.

     

    seems that what you want to do is

    DELIMITER ~
    CREATE TRIGGER updTrgr BEFORE UPDATE ON tester
    FOR EACH ROW BEGIN
        IF NEW.order <= OLD.order THEN
            SET NEW.order = OLD.order + 1;
        ENDIF;
    END;~
    DELIMITER ;

     

     

  4. sure it can be simplified...

     

    all your SELECT's can be reduced to just 1 SELECT

     

    play with this (not fully tested):

     

    SELECT `date`, count(`date`) AS daytotal, count(DISTINCT(`ip`)) AS singleip

    FROM `table`

    WHERE `date` between date_sub(curdate(), INTERVAL 7 DAY) and curdate()

    GROUP BY `date`;

     

    after that should be only a matter of loop thought the resulset and display the information.

     

    edited because I forgot the Group BY

     

     

  5. Fenway... could you please point me where do you got that information?

     

    I just checked the 5.6 Manual and it say that the limit for a TEXT field can not exceed 2 to the power of 16 ie. 65536 bytes... and I did test it in my machine with version 5.1.44 and that is correct... a TEXT field cannot exceed the limit

     

    maybe I'm not seeing something relevant in the manual.

     

    thank you.

     

  6. I will suggest to implement your categories - subcategories in a different and easy way

     

    Categories

     

    cat_id  INT,

    cat_name  VARCHAR,

    cat_parent INT

     

    for Master Categories the field cat_parent should be 0 or NULL  for Subcategories the cat_parent field will point to the Master category (cat_id)... this should simplify your query.

     

     

  7. ....
                 [b] FROM image_school[/b]
                  JOIN school
                  ON image_school.school_id = school.school_id
                  RIGHT JOIN image
                  ON image_school.image_id = image.image_id
              [b] FROM school_course[/b]
               JOIN course
               ON school_course.course_id = course.course_id
               JOIN school
               ON school_course.school_id = school.school_id 
               ORDER BY school_name";
               $result = mysql_query($query, $conn)
                  or die ("error retrieving course levels");

     

     

     

    2 times FROM ?.... I don't think so  ;)

  8. $r = mysqli_query ($dbc, $q) or die(mysqli_error($dbc)); // Run the query and show the error on failure... Do not use the "@" in front...

     

    you have a blank space after mysql_query... delete it and try...

    $r = mysqli_query($dbc, $q) or die(mysqli_error($dbc)); // Run the query and show the error on failure... Do not use the "@" in front...

  9. $q="SELECT horseID, total FROM enteredHorses";  
    
    $r = @mysqli_query ($dbc, $q); // Run the query.

     

    first: In your select (1st line) you didn't include the ORDER BY that I wrote in the code that I gave to you.

    second: re-write the second line in this way:

     

    $r = mysqli_query ($dbc, $q) or die(mysqli_error($dbc)); // Run the query and show the error on failure... Do not use the "@" in front...

  10. yes... you are right... is a lot of examples in the net/forums to solve what do you want...

     

    basically your form should include all the possibles search criteria that allow you to filter the final query results... in some cases you can use form fields which values depend on the value of previous field and they are populated querying the database also.

     

    search around this forum and others and you will find examples. 

  11. :confused:  I don't get it... if I understand correctly what you are trying to do is:

     

    - Read your table EnteredHorses and depending on the value of the column "total" assign the proper "place" to the horse.... right?

     

    so.. why don't do that in this way :

     

    $q="SELECT horseID, total FROM enteredHorses ORDER BY total DESC";  
    
    $r = mysqli_query ($dbc, $q) or trigger_error(mysqli_error($dbc));
    
    $place = 1;
    while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)) {
    
       $q = "UPDATE enteredHorses SET place = '$place' WHERE horse_id='".$row['horseID'] . "'";
       $r = mysqli_query ($dbc, $q) or trigger_error(mysqli_error($dbc));
    
       $place = $place + 1;
    
    }

     

    and even then, I will question why you need the column place if only with a simple select you can have the proper order, hence the horse's place.

     

  12. If the two table have a clear relationship as in your case, I rather prefer to implement/enforce the Referential Integrity at DataBase level with a FOREIGN KEY and an ON DELETE CASCADE. In that way you only be deleting from the "Master" table PEOPLE... the ON DELETE CASCADE will take care of automatically delete from the PeopleCon Table.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.