Exemplo n.º 1
0
/**
 * Retrieves the max id from table.
 */
function get_last_id($id, $table)
{
    $i = 0;
    $rNum = mt_rand(1, 9);
    do {
        $rNum .= mt_rand(0, 9);
    } while (++$i < 10);
    $query = mysql_query("SELECT {$id} FROM {$table}");
    if (mysql_num_rows() > 0) {
        get_last_id($id, $table);
    } else {
        return $rNum;
    }
}
Exemplo n.º 2
0
     die('Query failed.');
 }
 // Bind params, execute query, bind/fetch result, close stmt
 $stmt->bind_param('s', $url);
 $stmt->execute();
 $stmt->store_result();
 $stmt->bind_result($surl);
 $stmt->fetch();
 // If URL not in database, add it. Otherwise, get the existing short URL.
 if ($stmt->num_rows == 0) {
     // Case 1: URL not in database.
     $stmt->close();
     // Exit condition variable
     $surl_is_new = false;
     // Get last id
     $id = get_last_id($mysqli, $url);
     // Find a new short url
     while ($surl_is_new == false) {
         // Get next id/hash it
         $id++;
         $surl = get_id_hash($id);
         // Check if hash in database, if it's not then use it
         // Prepare statement
         if (!($stmt = $mysqli->prepare("SELECT id from urls where shorturl=?"))) {
             die('Query failed.');
         }
         // Bind params, execute query, bind/fetch result
         $stmt->bind_param('s', $surl);
         $stmt->execute();
         $stmt->store_result();
         $stmt->fetch();
Exemplo n.º 3
0
"  class="meja1" style="background-color:<?php 
        echo $row['tt_color'];
        ?>
">
	
				<div class="led_name"><?php 
        echo $row['table_name'];
        ?>
</div>
				<div class="led_ip"><?php 
        echo $row['table_ip'];
        ?>
</div>
				<div class="meja_title">
                <?php 
        $last_id = get_last_id($row['table_id']);
        if ($last_id) {
            $get_value = read_last_id($last_id);
            //echo $get_value['value'];
        } else {
            //echo "kosong";
        }
        ?>

				<canvas id="myCanvas<?php 
        echo $row['table_id'];
        ?>
" width="250" height="60"><div class="canvasfallback">[No canvas support]</div></canvas>

              </div>
				<span class="tooltip-content clearfix">
Exemplo n.º 4
0
<!DOCTYPE html>
<?php 
@session_start();
require_once "../db/db.php";
if (isset($_GET['curriculum_code'])) {
    $get_curriculum_code = $_GET['curriculum_code'];
}
if (isset($_POST['submit'])) {
    $category_name = $_POST['category_name'];
    if (true) {
        if ($category_name) {
            if (true) {
                $check = mysql_query("SELECT * FROM subject_category_t WHERE category_name = '{$category_name}'");
                //$check2 = mysql_query("SELECT * FROM year_level_t WHERE lvl_name = '$lvl_name'");
                if (mysql_num_rows($check) < 1) {
                    $id = get_last_id();
                    mysql_query("START TRANSACTION");
                    mysql_query("INSERT INTO subject_category_t VALUES('{$id}','{$category_name}')") or die(mysql_error());
                    mysql_query("COMMIT;");
                    //header("location: curriculums.php");
                } else {
                    $errormsg = "There is already an entry for that category name";
                }
            } else {
                $errormsg = "Maximum Unit is expected to be an integer.";
            }
        } else {
            $errormsg = "Please enter a category name.";
        }
    } else {
        $errormsg = "Please enter a level for your curriculum.";
Exemplo n.º 5
0
 $first_name = ucwords($first_name);
 $last_name = ucwords($last_name);
 $email = strtolower($email);
 //check if email is already registered
 $sql = "SELECT * FROM patients WHERE email = '{$email}' AND active=1";
 $res = mysql_query($sql);
 if (mysql_num_rows($res) > 0) {
     array_push($error, "Email already registered, try different email!");
 } else {
     //insert new patient
     $sql = "INSERT INTO patients (first_name, last_name, phone, email, source, notes, date)\r\n\t\t\t\t\tVALUES('{$first_name}', '{$last_name}', '{$phone_number}', '{$email}', '{$source}', '', NOW())";
     mysql_query($sql);
     $id = mysql_insert_id();
     if ($id > 0) {
         //create card
         $card_id = get_last_id("card_id", "cards");
         $card_file = $card_id . ".pdf";
         //replace information on html
         $htmlFileLocation = $_SERVER['DOCUMENT_ROOT'] . "/printrxcard/card.html";
         $html = file_get_contents($htmlFileLocation);
         $html = fill_card($html, $site);
         $html = str_replace("{full_name}", $first_name . ' ' . $last_name, $html);
         //ful_name
         $html = str_replace("{card_id}", $card_id, $html);
         //card_id
         //output pdf file
         $mpdf->WriteHTML($html);
         $outputFileLocation = $_SERVER['DOCUMENT_ROOT'] . "/printrxcard/cards/{$card_file}";
         $mpdf->Output($outputFileLocation, 'F');
         //save card
         mysql_query("INSERT INTO cards (card_id, id_patient, card, date)\r\n\t\t\t\t\t\tVALUES('{$card_id}', '{$id}', '{$outputFileLocation}', NOW())");
Exemplo n.º 6
0
         $row['type'] = '';
         $row['value1'] = '';
         $row['value2'] = '';
         $row['value3'] = '';
         $row['colour1'] = '';
         $row['colour2'] = '';
         $row['colour3'] = '';
     }
     $action = "order.php?page=save_led&table_id={$table_id}";
     $close_button = "order.php";
     include '../views/order/form_led.php';
     //get_footer();
     break;
 case 'form_load':
     $table_id = isset($_GET['id']) ? $_GET['id'] : '';
     $last_id = get_last_id($table_id);
     $row['table_name'] = get_table_name($table_id);
     $row['table_ip'] = get_table_ip($table_id);
     echo "Gate : " . $row['table_name'] . "<br>";
     echo "IP address : " . $row['table_ip'] . "<br>";
     if ($last_id) {
         $get_value = read_last_id($last_id);
         $row['type'] = $get_value['type'];
         if ($get_value['type'] == 2) {
             $led_value = $get_value['value1'];
             $led_colour = $get_value['colour1_name'];
         } else {
             $led_value = $get_value['value1'] . " | " . $get_value['value2_name'] . " | " . $get_value['value3_name'];
             $led_colour = $get_value['colour1_name'] . " | " . $get_value['colour2_name'] . " | " . $get_value['colour3_name'];
         }
         $led_value = strtoupper($led_value);