当前位置: 首页>>代码示例>>PHP>>正文


PHP database::send_sql方法代码示例

本文整理汇总了PHP中database::send_sql方法的典型用法代码示例。如果您正苦于以下问题:PHP database::send_sql方法的具体用法?PHP database::send_sql怎么用?PHP database::send_sql使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在database的用法示例。


在下文中一共展示了database::send_sql方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getAllCategoriesDetails

function getAllCategoriesDetails()
{
    $db = new database();
    $db->pick_db("workoutlog");
    $res = $db->send_sql("SELECT table_name, column_name, data_type FROM information_schema.columns WHERE table_schema='workoutlog' and table_name LIKE 'tbl_workoutlog_category_%'");
    $categories = $res->fetch_all(MYSQLI_ASSOC);
    foreach ($categories as $category) {
        $categoryName = substr($category['table_name'], 24);
        $columnName = $category['column_name'];
        $columnDataType = $category['data_type'];
        if (strtolower($columnName) != strtolower($categoryName . "Id") && strtolower($columnName) != strtolower("ExerciseId")) {
            $allCategoriesDetails[$categoryName][$columnName] = $columnDataType;
        }
    }
    return json_encode($allCategoriesDetails);
}
开发者ID:jdevince,项目名称:WorkoutLogger,代码行数:16,代码来源:commonFuncs.php

示例2: database

    </form>
    </div>
    </div>

	<div class="container">

		<fieldset>
		<legend>Content</legend>
		<?php 
//change to your path
include "./include/DB.php";
$LIMITATION = 10;
$db = new database();
$db->connect();
$query_question = "SELECT user.Name,questions.Title,questions.time,questions.QID\n                      FROM `user` \n                      INNER JOIN `questions`\n                      ON user.UID=questions.UID\n";
if (!($res_question = $db->send_sql($query_question))) {
    $db->disconnect();
    echo "Get Questions failed!<br>\n";
    return -1;
}
$num = mysqli_num_rows($res_question);
$i = 0;
while ($i < $num) {
    $content = $res_question->fetch_assoc();
    $content_question[$i][0] = $content['Name'];
    $content_question[$i][1] = $content['Title'];
    $content_question[$i][2] = $content['time'];
    $content_question[$i][3] = $content['QID'];
    $i++;
}
$i = 0;
开发者ID:ammisme,项目名称:546Final,代码行数:31,代码来源:index.php

示例3: implode

     }
     return implode($pass);
     //turn the array into a string
 }
 $db = new database();
 $db->setup(DB_USER, DB_PASS, DB_HOST, DB_NAME);
 if ($_POST["proftype"] == "advisor") {
     ini_set('SMTP', 'localhost');
     ini_set('sendmail_from', 'kjp396@gmail.com');
     $header = 'From: webmaster@example.com' . "\r\n" . 'Reply-To: webmaster@example.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion();
     $rpass = randomPassword();
     echo "Advisor has been created and password is ";
     echo $rpass;
     //mail($profmail,"password for subject waiver account",$rpass,$header);
     $createinstructor = "INSERT INTO instructor (i_id, i_name,ph_no,i_email,advisor_bool,admin_bool,department) VALUES ('" . $profid . "', '" . $profname . "', '" . $profphone . "', '" . $profmail . "', '1', '0','" . $profdept . "')";
     $db->send_sql($createinstructor);
     $hpassword = md5($rpass);
     //Hashing the password
     $createlogin = "INSERT INTO login(id,password)VALUES('" . $profid . "','" . $hpassword . "')";
     $db->send_sql($createlogin);
 } elseif ($_POST["proftype"] == "admin") {
     $createinstructor = "INSERT INTO instructor (i_id, i_name,ph_no,i_email,advisor_bool,admin_bool,department) VALUES ('" . $profid . "', '" . $profname . "', '" . $profphone . "', '" . $profmail . "', '0', '1','" . $profdept . "')";
     $db->send_sql($createinstructor);
     $rpass = randomPassword();
     echo "Admin has been created and password is ";
     echo $rpass;
     $hpassword = md5($rpass);
     //Hashing the password
     $createlogin = "INSERT INTO login(id,password)VALUES('" . $profid . "','" . $hpassword . "')";
     $db->send_sql($createlogin);
 } else {
开发者ID:sagarshah16,项目名称:waiver-system,代码行数:31,代码来源:admin2.php

示例4: database

header('Content-Type: application/json');
$db = new database();
$results = array();
if (isset($_POST['post']) && isset($_POST['for_name']) && $_POST['post'] != '') {
    if (isset($_POST['showName'])) {
        $showName = $db->escape($_POST['showName']);
        if ($showName === true || $showName === 'true') {
            $showName = 1;
        } else {
            $showName = 0;
        }
    } else {
        $showName = 0;
    }
    if ($session->checkLoggedIn() === true) {
        $db->send_sql("insert into ownage(u_id) values ('{$session->uid}')");
        $ownage = $db->insert_id();
        date_default_timezone_set('UTC');
        $post = $db->escape($_POST['post']);
        $for_name = $db->escape($_POST['for_name']);
        $query = 'insert into posts(u_id, post, showName, ownage_id, for_name) values (\'' . $session->uid . '\', \'' . $post . '\',  \'' . $showName . '\', \'' . $ownage . '\', \'' . $for_name . '\')';
        $db->send_sql($query);
        array_push($results, "success");
    } else {
        array_push($results, "Please log in");
    }
} else {
    if (isset($_POST['delete']) && $_POST['delete'] != '') {
        $delete = $db->escape($_POST['delete']);
        if ($session->isAdmin()) {
            $query = 'update posts set hidden=1 where p_id=\'' . $delete . '\'';
开发者ID:NicholasAntonov,项目名称:stevens-comments,代码行数:31,代码来源:userPost.php

示例5: database

<?php

session_start();
include "databaseClassMySQLi.php";
//include("projconfig.php");
$db = new database();
$db->setup(DB_USER, DB_PASS, DB_HOST, DB_NAME);
if (isset($_POST['sit']) && isset($_POST['password'])) {
    $sit = addslashes(strip_tags($_POST['sit']));
    $password = md5($_POST['password']);
    $sql = "SELECT * FROM login WHERE id='{$sit}' AND password='{$password}' ";
    $res = $db->send_sql($sql);
    $row = mysqli_num_rows($res);
    if ($row > 0) {
        $_SESSION['cwid'] = $sit;
        echo 'true';
    } else {
        echo 'false';
    }
}
开发者ID:sagarshah16,项目名称:waiver-system,代码行数:20,代码来源:StudentLogin.php

示例6: database

if (!isset($_POST["submit"])) {
    echo 'Please use the form to enter the fields';
} else {
    $courseprofname = $_POST["courseprofname"];
    $db1 = new database();
    $db1->setup(DB_USER, DB_PASS, DB_HOST, DB_NAME);
    $courseprofid = "SELECT i_id FROM instructor WHERE i_name='" . $courseprofname . "'";
    $res = $db1->send_sql($courseprofid);
    $courserefid = "SELECT course_id FROM course WHERE i_id='" . $row['i_id'] . "'";
    $res1 = $db1->send_sql($courserefid);
    $db2 = new database();
    $db2->setup(DB_USER, DB_PASS, DB_HOST, DB_NAME);
    while (($fetch = mysqli_fetch_array($res1)) != NULL) {
        $row = $db1->next_row();
        $selfile = "SELECT subq_id FROM files WHERE course_id='" . $row1['course_id'] . "'";
        $res3 = $db2->send_sql($selfile);
        $row3 = $db2->next_row();
        $selsubq = "SELECT s_id FROM submissionqueue WHERE subq_id='" . $row3['subq_id'] . "'";
        $res4 = $db2->send_sql($selsubq);
        $row4 = $db2->next_row();
        $delstud = "DELETE FROM student WHERE s_id='" . $row4['s_id'] . "'";
        $res5 = $db2->send_sql($delstud);
        $delsubq = "DELETE FROM submissionqueue WHERE subq_id='" . $row3['subq_id'] . "'";
        $res6 = $db2->send_sql($delsubq);
        /*$delfile="DELETE FROM files WHERE course_id='".$row1['course_id']."'";
                                            $res7=$db1->send_sql($delfile);
        
                                            /*$delsubt="DELETE FROM submissiontype WHERE course_id='".$row1['course_id']."'";
                                            $res8=$db1->send_sql($delsubt);*/
        $delcoursename = "DELETE FROM course WHERE course_id='" . $row['i_id'] . "'";
        $res9 = $db2->send_sql($delcoursename);
开发者ID:sagarshah16,项目名称:waiver-system,代码行数:31,代码来源:deletecourse2.php

示例7: database

<head>
    <title>File upload</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <link rel="stylesheet" type="text/css" href="style.css">
</head>
<body bgcolor="#E6E6FA">
    <form id = "theForm" action = "add_file.php" method = "POST" enctype = "multipart/form-data">
        <?php 
include "headerStudent.php";
include "databaseClassMySQLi.php";
//include("projconfig.php");
$databaseObj = new database();
$databaseObj->setup(DB_USER, DB_PASS, DB_HOST, DB_NAME);
$courseid = addslashes(strip_tags($_POST["course"]));
$query = "SELECT * FROM submissiontype WHERE course_id='" . $courseid . "'";
$result = $databaseObj->send_sql($query);
while ($row = $databaseObj->next_row()) {
    $jsonData = stripslashes($row['submission_type']);
    $jsonArray = json_decode($jsonData, true);
    foreach ($jsonArray as $key => $key_v) {
        echo "<b>" . $key . ":</b><br>";
        foreach ($key_v as $value => $element) {
            echo "<label for='{$element}'>{$element}</label>";
            echo "<input type='file' name='{$element}' /><br/>";
        }
    }
}
?>
        <input type ="hidden" name = "hid" value = "<?php 
if (isset($_POST['course'])) {
    echo $_POST['course'];
开发者ID:sagarshah16,项目名称:waiver-system,代码行数:31,代码来源:upload.php

示例8: database

ob_start();
session_start();
include "databaseClassMySQLi.php";
//include("projconfig.php");
$db = new database();
$db->setup(DB_USER, DB_PASS, DB_HOST, DB_NAME);
$datab = new database();
$datab->setup(DB_USER, DB_PASS, DB_HOST, DB_NAME);
if (isset($_POST['sit']) && isset($_POST['password'])) {
    $sid = addslashes(strip_tags($_POST['sit']));
    $password = md5($_POST['password']);
    //   $password=$_POST['password'];
    $sit = intval($sid);
    $queryIns = "SELECT * FROM instructor WHERE i_id=" . $sit;
    $query = "SELECT * FROM login WHERE id='{$sit}' AND password='{$password}' ";
    $res1 = $db->send_sql($queryIns);
    $row1 = mysqli_num_rows($res1);
    $ans = mysqli_fetch_array($res1);
    $admin_bool = $ans['admin_bool'];
    $res = $datab->send_sql($query);
    $row = mysqli_num_rows($res);
    if ($row1 > 0) {
        if ($row > 0) {
            $_SESSION['admin_bool'] = $admin_bool;
            $_SESSION['cwid'] = $sit;
            echo 'true';
        }
    } else {
        echo 'false';
    }
}
开发者ID:sagarshah16,项目名称:waiver-system,代码行数:31,代码来源:ProfessorLogin.php

示例9: database

include "Includes/commonFuncs.php";
if (isset($_POST["exercises"]) && isset($_POST["date"]) && isset($_SESSION["username"])) {
    $exercises = $_POST["exercises"];
    $date = $_POST["date"];
    $username = $_SESSION["username"];
    $db = new database();
    $db->pick_db("workoutlog");
    $userId = getUserIdFromUsername($username);
    if ($userId != null) {
        //Add workout to tbl_workoutlog_workout, get workoutId
        $stmt = $db->prepare("INSERT INTO tbl_workoutlog_workout (UserId, WorkoutDate) VALUES (?, STR_TO_DATE(?, '%Y-%m-%d'))");
        $stmt->bind_param('is', $userId, $date);
        $stmt->execute();
        if ($stmt->affected_rows == 1) {
            $stmt->free_result();
            $res = $db->send_sql("SELECT LAST_INSERT_ID() AS Id");
            if ($res->num_rows > 0) {
                $row = $res->fetch_assoc();
                $workoutId = $row['Id'];
                foreach ($exercises as $exercise) {
                    //Add each exercise to tbl_WorkoutLog_Exercise linking to the workoutId
                    $stmt = $db->prepare("SELECT ExerciseNameId FROM tbl_workoutlog_exercisename WHERE ExerciseName = ?");
                    $stmt->bind_param('s', $exercise['name']);
                    $stmt->execute();
                    $stmt->bind_result($exerciseNameId);
                    $stmt->fetch();
                    $stmt->free_result();
                    if ($exerciseNameId == null) {
                        //New exercise name, add it to tbl_workoutlog_exercisename
                        $stmt = $db->prepare("INSERT INTO tbl_workoutlog_exercisename (ExerciseName, ExerciseCategory) VALUE (?, ?)");
                        $stmt->bind_param('ss', $exercise['name'], $exercise['category']);
开发者ID:jdevince,项目名称:WorkoutLogger,代码行数:31,代码来源:saveWorkout.php

示例10: header

<?php

ob_start();
session_start();
if (!isset($_SESSION['username'])) {
    header('Location:index.php');
}
include "./Class_Database.php";
$db = new database();
//$db->setup("kaushal", "kaushal", "localhost", "jobportaldb");
$userid = $_GET['id'];
$query = "Select * from users where id_user={$userid}";
$res = $db->send_sql($query);
if (mysql_num_rows($res) > 0) {
    while ($row = mysql_fetch_array($res)) {
        $to = stripslashes($row["email_user"]);
    }
}
if (isset($res)) {
    unset($res);
}
$username = $_SESSION['username'];
$query1 = "Select * from admin where username='{$username}' and usertype='admin'";
$res1 = $db->send_sql($query1);
if (mysql_num_rows($res1) > 0) {
    while ($row = mysql_fetch_array($res1)) {
        $from = stripslashes($row["email"]);
    }
}
?>
<html xmlns="http://www.w3.org/1999/xhtml">
开发者ID:sagarshah16,项目名称:job-portal,代码行数:31,代码来源:adminsendmessage.php

示例11: database

			<header> <h1> Waiver Request Form</h1><header>
		<div id="form">
			<form id="theForm" method="post" action="upload.php" >
				<p><label>Select your major:</label>
				<select name="department" required="">
				<option value="" disabled selected>---Select your major-----</option>
							
				<?php 
include "databaseClassMySQLi.php";
//include ("projconfig.php");
$db = new database();
$db->setup(DB_USER, DB_PASS, DB_HOST, DB_NAME);
$res = $db->send_sql("SELECT DISTINCT department FROM course");
$db1 = new database();
$db1->setup(DB_USER, DB_PASS, DB_HOST, DB_NAME);
$res1 = $db1->send_sql("SELECT DISTINCT course_id FROM course");
while (($row = mysqli_fetch_array($res)) != NULL) {
    echo "<option>" . $row['department'] . "</option>";
}
?>
				
				</select></p><br>
				
				<p> <label for="course">Select the course you wish to enroll:</label>
						
				<select name="course" required="">
				<option value="" disabled selected>-----Select the course you want the waiver for----</option>
				<?php 
while (($row = mysqli_fetch_array($res1)) != NULL) {
    echo "<option>" . $row['course_id'] . "</option>";
}
开发者ID:sagarshah16,项目名称:waiver-system,代码行数:31,代码来源:waiver.php

示例12: database

		<header>
				<center><h1>Remove Instructor and Remove Course Form</h1></center>
		</header>
		
		<div class="form">
	
			<form id="deletecourse1" name="deletecourse1" action="deletecourse2.php" method="post">
			
				<p><label>Enter the instructor you wish to remove</label></p><br>
				<select name="courseprofname">
				<option>---Select the name of the professor---</option>-->
				
				<?php 
include "databaseClassMySQLi.php";
$db = new database();
$db->setup(DB_USER, DB_PASS, DB_HOST, DB_NAME);
$res = $db->send_sql("SELECT * FROM instructor");
while (($row = mysqli_fetch_array($res)) != NULL) {
    echo "<option>" . $row['i_name'] . "</option>";
}
?>
				</select><br><br>
				
				
				
				<input type="submit" name="submit">
			</form>
		</div>
	</div>
	</body>
</html>
开发者ID:sagarshah16,项目名称:waiver-system,代码行数:31,代码来源:deletecourse1.php

示例13: database

			<p><label>Enter the pre-requisite course required</label></p><br>
				<input type="text" name="prerequisite" pattern="^[a-zA-Z]{2,3}[0-9]{3}" title="Enter valid course ID, eg:CS123" required=""><br>
				
			<p><label>Enter the name of the professor</label></p><br>
				<select name="courseprofname" required="">
				<option>---Select the name of the professor---</option>-->
				
				<?php 
include "databaseClassMySQLi.php";
//include("projconfig.php");
$db = new database();
$db1 = new database();
$db->setup(DB_USER, DB_PASS, "localhost", DB_NAME);
$db1->setup(DB_USER, DB_PASS, "localhost", DB_NAME);
$res = $db->send_sql("SELECT DISTINCT i_name FROM instructor");
$res1 = $db1->send_sql("SELECT DISTINCT department FROM course");
//$num_row= mysqli_num_rows($res);
while (($row = mysqli_fetch_array($res)) != NULL) {
    //$row = $db->next_row();
    echo "<option>" . $row['i_name'] . "</option>";
    //$num_row=$num_row-1;
}
?>
				</select>
				
				<p><label>Enter the name of the major</label></p><br>
				<select name="coursemajor" required="">
					<option>---Select the name of the major---</option>
					<option value="NONE">---Select your major---
							 
							<option value="BME">Biomedical Engineering
开发者ID:sagarshah16,项目名称:waiver-system,代码行数:31,代码来源:createcourse1.php

示例14: addslashes

		<fieldset>
			<legend>Search Result</legend>	
<?php 
$search_word = $_POST["search_input"];
if (empty($search_word)) {
    echo "None input";
} else {
    $search_word2 = addslashes($search_word);
    //echo $search_word2;
    include "../include/DB.php";
    $db = new database();
    $db->connect();
    $query_search_title = "SELECT user.Name,questions.Title,questions.time,questions.QID\r\n\t               From `user`\r\n\t\t\t\t   INNER JOIN `questions`\r\n\t\t\t\t   ON user.UID=questions.UID\r\n\t\t\t\t   where Title Like '%{$search_word2}%'\r\n\t";
    $query_search_content = "SELECT user.Name,questions.Content,questions.time,questions.QID,questions.Title\r\n\t                       From `user`\r\n\t\t\t\t\t\t   INNER JOIN `questions`\r\n\t\t\t\t\t\t   ON user.UID=questions.UID\r\n\t\t\t\t\t\t   where Content LIKE '%{$search_word2}%'\r\n\t";
    if (!($res_search = $db->send_sql($query_search_title))) {
        $db->disconnect();
        echo "Get search result failed!<br>\n";
        return -1;
    }
    $i = 0;
    $num_title = mysqli_num_rows($res_search);
    while ($i < $num_title) {
        $content = $res_search->fetch_assoc();
        $str = $content['Title'];
        $rep = "<span style=\"background-color: #66CCFF\">" . $search_word . "</span>";
        $str = preg_replace('/' . $search_word . '/i', $rep, $str);
        echo "<div class=\"jumbotron\">\n";
        echo "<h4><a href=\"edit_answer.php?var=" . $content['QID'] . "\" >" . $str . "</a></h4>\n";
        echo "<h6>Poster:" . $content['Name'] . "</h6>\n";
        echo "<h6>Time:" . $content['time'] . "</h6>\n";
开发者ID:ammisme,项目名称:546Final,代码行数:30,代码来源:search.php

示例15: database

<?php

//get
//votePost.php?p_id=1&up
//votePost.php?p_id=1&down
require_once "include/databaseClassMySQLi.php";
require_once "include/session.php";
header('Content-Type: application/json');
$db = new database();
$results = array();
if (isset($_POST['p_id']) && $_POST['p_id'] != '') {
    $p_id = $db->escape($_POST['p_id']);
    if (isset($_POST['up'])) {
        $query = 'select value from post_votes where p_id=\'' . $p_id . '\' and u_id=\'' . $session->uid . '\'';
        $db->send_sql($query);
        $row = $db->next_row();
        if ($row === false || empty($row)) {
            $query = 'insert into post_votes (p_id, u_id, value) values(\'' . $p_id . '\', \'' . $session->uid . '\', 1)';
            $db->send_sql($query);
            $query = 'update posts set votes = votes + 1 where p_id=' . $p_id;
            $db->send_sql($query);
        } else {
            $query = 'update post_votes set value=1 where p_id=\'' . $p_id . '\' and u_id=\'' . $session->uid . '\'';
            $db->send_sql($query);
            $value = $row['value'];
            if ($value == -1) {
                $query = 'update posts set votes = votes + 2 where p_id=\'' . $p_id . '\'';
                $db->send_sql($query);
            }
        }
    } else {
开发者ID:NicholasAntonov,项目名称:stevens-comments,代码行数:31,代码来源:votePost.php


注:本文中的database::send_sql方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。