Example #1
0
 function get_all_families_from_one_society($familiesbysociety, $connection)
 {
     # Get all families from one society
     $query = "SELECT * FROM families WHERE community_id = '{$familiesbysociety}'";
     $result = n_query($query, $connection);
     while ($row = mysql_fetch_assoc($result)) {
         if ($row != FALSE) {
             foreach ($row as $key => $value) {
                 echo $value . " - ";
             }
         } else {
             echo "There are no families in this society.";
         }
     }
 }
Example #2
0
 function get_details_about_selected_society($connection = NULL, $name_of_society)
 {
     ####################################################
     # arrguments:
     # 1. connection - resource
     # 2. name_of_society - post value after validation
     ####################################################
     ##################################
     # This is for development only
     #// var_dump($_POST);
     #// print_r($_POST);
     ##################################
     # Insert the post value into a variable
     $singlesociety = $name_of_society;
     /* Get all the data from table 'society' 
     			where the value match $singlesociety */
     ##########################################
     #
     # TODO we have a problem in the sql, what if we have 2 results?
     # we get only one answer
     ##########################################
     $query = "SELECT * FROM society WHERE name = '{$singlesociety}'";
     $result = n_query($query, $connection);
     # Get the result from the query and convert it to array
     # and insert into variable $row
     # We are only intersted in one result
     $row = mysql_fetch_assoc($result);
     # for development use
     # var_dump($row);
     #########################
     # We wanna make sure we have result before running foreach loop
     if ($row != FALSE) {
         # Go through every value in the row and print it
         foreach ($row as $key => $value) {
             echo $value . " - ";
         }
         # If we dont have result:
     } else {
         echo "This society doesn't exist.";
     }
     # END IF
 }
Example #3
0
    $result = n_query($query, $connection);
    $row = mysql_fetch_assoc($result);
    # check if family exists, and if not than:
    if ($row != FALSE) {
        // we now know that family exists
        //
        // now we're checking if society exists
        $query = "SELECT * FROM society WHERE name = '{$societytomoveto}'";
        $result = n_query($query, $connection);
        $row = mysql_fetch_assoc($result);
        if ($row != FALSE) {
            // society exists
            //
            // Now we are updating the selected family community
            $query = "UPDATE families SET community_id = '{$societytomoveto}' WHERE family_name = '{$familytomove}'";
            $result = n_query($query, $connection);
            // var_dump($result);
            if ($result == TRUE) {
                echo "Success!";
            } else {
                echo "Society not found.";
            }
        } else {
            echo "Family not found.";
        }
    } else {
        echo "Please input both family name and society name.";
    }
}
?>
			</div>