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


PHP mysqli_num_rows函数代码示例

本文整理汇总了PHP中mysqli_num_rows函数的典型用法代码示例。如果您正苦于以下问题:PHP mysqli_num_rows函数的具体用法?PHP mysqli_num_rows怎么用?PHP mysqli_num_rows使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: login

 function login()
 {
     $link = $this->db_connection();
     $pass = $_POST['user_password'];
     $user = $_POST['user_name'];
     $query = "SELECT password, user_type, name FROM user WHERE user_name='{$user}'";
     $result = mysqli_query($link, $query) or die(mysqli_error($link));
     if (mysqli_num_rows($result) == 1) {
         $result = mysqli_fetch_array($result);
         //$hash= password_hash($result[0], PASSWORD_DEFAULT);
         //$hash=$result[0];
         //echo $hash;
         //print_r($result);
         //           if($result[0]==$pass){
         if (password_verify($pass, $result[0])) {
             session_start();
             $_SESSION['type'] = $result[1];
             $_SESSION['name'] = $result[2];
             //echo $_SESSION['type'].'<br>'.$_SESSION['name']=$result[2];
             header("Location:card.php");
         } else {
             return $error = TRUE;
         }
     } else {
         return $error = TRUE;
     }
 }
开发者ID:usmanali126,项目名称:injectpoint,代码行数:27,代码来源:inject_record_1.php

示例2: sc_check_priv

function sc_check_priv($prob_id, $opened, $user)
{
    if (!function_exists('check_priv')) {
        require __DIR__ . '/privilege.php';
    }
    if (isset($_SESSION['user'])) {
        if (strcmp($user, $_SESSION['user']) == 0 || check_priv(PRIV_SOURCE)) {
            return TRUE;
        }
    }
    require __DIR__ . '/../conf/database.php';
    if (!defined('PROB_HAS_TEX')) {
        require __DIR__ . '/../lib/problem_flags.php';
    }
    if ($opened) {
        $row = mysqli_fetch_row(mysqli_query($con, "select has_tex from problem where problem_id={$prob_id}"));
        if (!$row) {
            return _('There\'s no such problem');
        }
        $prob_flag = $row[0];
        if ($prob_flag & PROB_IS_HIDE && !check_priv(PRIV_INSIDER)) {
            return _('Looks like you can\'t access this page');
        }
        if ($prob_flag & PROB_DISABLE_OPENSOURCE) {
            return _('This solution is not open-source');
        } else {
            if ($prob_flag & PROB_SOLVED_OPENSOURCE) {
                if (isset($_SESSION['user'])) {
                    $query = 'select min(result) from solution where user_id=\'' . $_SESSION['user'] . "' and problem_id={$prob_id} group by problem_id";
                    $user_status = mysqli_query($con, $query);
                    $row = mysqli_fetch_row($user_status);
                    if ($row && $row[0] == 0) {
                        return TRUE;
                    }
                }
                return _('You can\'t see me before solving it');
            } else {
                if (isset($_SESSION['user'])) {
                    $res = mysqli_query($con, "SELECT contest.contest_id,co.contest_id from contest\n                                       RIGHT JOIN (select contest_id from contest_status where user_id='" . $_SESSION['user'] . "' and leave_time is NULL) as cs on (contest.contest_id=cs.contest_id)\n                                       LEFT JOIN (select contest_id from contest_problem where problem_id={$prob_id}) as cp on (contest.contest_id=cp.contest_id)\n                                       LEFT JOIN (select contest_id from contest_owner where user_id='" . $_SESSION['user'] . "') as co on (contest.contest_id=co.contest_id)\n                                       where NOW()>start_time and NOW()<end_time and contest.hide_source_code");
                    $num = mysqli_num_rows($res);
                    if ($num > 0) {
                        $accessible = false;
                        while ($row = mysqli_fetch_row($res)) {
                            if (!is_null($row[1])) {
                                $accessible = true;
                            }
                        }
                        if ($accessible) {
                            return TRUE;
                        } else {
                            return _('You can\'t see me before the contest ends');
                        }
                    }
                    return TRUE;
                }
            }
        }
    }
    return _('Looks like you can\'t access this page');
}
开发者ID:CDFLS,项目名称:CWOJ,代码行数:60,代码来源:sourcecode.php

示例3: add_eleve

function add_eleve($_login, $_nom, $_prenom, $_civilite, $_naissance, $_elenoet = 0)
{
    // Fonction d'ajout d'un élève dans la base Gepi
    if ($_civilite != "M" && $_civilite != "F") {
        if ($_civilite == 1) {
            $_civilite = "M";
        } elseif ($_civilite == 0) {
            $_civilite = "F";
        } else {
            $_civilite = "F";
        }
    }
    // Si l'élève existe déjà, on met simplement à jour ses informations...
    $test = mysqli_query($GLOBALS["mysqli"], "SELECT login FROM eleves WHERE login = '" . $_login . "'");
    if (mysqli_num_rows($test) > 0) {
        $record = mysqli_query($GLOBALS["mysqli"], "UPDATE eleves SET nom = '" . $_nom . "', prenom = '" . $_prenom . "', sexe = '" . $_civilite . "', naissance = '" . $_naissance . "', elenoet = '" . $_elenoet . "' WHERE login = '" . $_login . "'");
    } else {
        $query = "INSERT into eleves SET\n        login= '" . $_login . "',\n        nom = '" . $_nom . "',\n        prenom = '" . $_prenom . "',\n        sexe = '" . $_civilite . "',\n        naissance = '" . $_naissance . "',\n        elenoet = '" . $_elenoet . "'";
        $record = mysqli_query($GLOBALS["mysqli"], $query);
    }
    if ($record) {
        return true;
    } else {
        return false;
    }
}
开发者ID:alhousseyni,项目名称:gepi,代码行数:26,代码来源:eleves.php

示例4: request_crowd_report

/**
 *  Returns the crowd report of a certain room
 *  @param mysqli $db database to retrieve data from
 *  @param string $company the company where we want to retrieve data of room from
 *  @param string $branch specific address of the room of interest
 *  @param string $room the room number of interest
 *  @return json-encoded value containing data about the crowdedness of the room
 */
function request_crowd_report($db, $company, $branch, $room)
{
    $query = "SELECT c.company_name, b.branch_address, r.room_id, r.room_number, r.people_in, r.people_out,\n              r.max_capacity, r.date, r.time FROM `company` AS c\n              INNER JOIN `branch` AS b on c.company_id = b.company_id\n              INNER JOIN `room` AS r on b.branch_id = r.branch_id\n              WHERE r.room_number = '{$room}' AND b.branch_address = '{$branch}' AND c.company_name = '{$company}'";
    $results = $db->query($query);
    $exists = mysqli_num_rows($results);
    //Set Not Found error if no rooms exist or wrong company/branch for a room
    if ($exists) {
        $rooms = $results->fetch_assoc();
        $total_in = $rooms['people_in'];
        $total_out = $rooms['people_out'];
        $max = $rooms['max_capacity'];
        $time = $rooms['time'];
        $date = $rooms['date'];
        $curr_number = $total_in - $total_out;
        //Make sure crowd_percent is greater than or equal to 0 or less than or equal to 100
        if ($curr_number >= 0) {
            $crowd_percent = round(($total_in - $total_out) / $max * 100);
            if ($crowd_percent > 100) {
                $crowd_percent = 100;
            }
        } else {
            $crowd_percent = 0;
        }
        $room_info = array("company" => $company, "address" => $branch, "room" => $room, "date" => $date, "time" => $time, "crowd" => $crowd_percent);
        return json_encode(array("crowd" => $room_info));
    } else {
        http_response_code(404);
        exit;
    }
}
开发者ID:robertozimek,项目名称:crowdcontrol,代码行数:38,代码来源:request_functions.php

示例5: login_check

function login_check($sql)
{
    // Überprüfe, ob alle Session-Variablen gesetzt sind
    if (isset($_SESSION['nutzerID'], $_SESSION['name'], $_SESSION['login_string'])) {
        $nutzerID = $_SESSION['nutzerID'];
        $login_string = $_SESSION['login_string'];
        $name = $_SESSION['name'];
        // Hole den user-agent string des Benutzers.
        $nutzer_browser = $_SERVER['HTTP_USER_AGENT'];
        $login_ab = "SELECT * FROM nutzer WHERE nutzerID = '" . $nutzerID . "';";
        if ($login_an = mysqli_query($sql, $login_ab)) {
            if (mysqli_num_rows($login_an) == 1) {
                $login = mysqli_fetch_array($login_an);
                $login_check = hash('sha512', $login['passwort'] . $nutzer_browser);
                if ($login_check == $login_string) {
                    // Eingeloggt!!!!
                    return true;
                } else {
                    // Nicht eingeloggt
                    return false;
                }
            } else {
                return false;
            }
        } else {
            return false;
        }
    } else {
        return false;
    }
}
开发者ID:Obihoernchen91,项目名称:studiouhr,代码行数:31,代码来源:functions.php

示例6: ExportTable

function ExportTable($conn, $title, $filter, $dbtable, $dbjoin = "", $joinfield = "")
{
    $query = "SELECT * FROM {$dbtable}";
    if ($dbjoin) {
        $query .= " INNER JOIN {$dbjoin} ON {$dbtable}.{$joinfield}={$dbjoin}.{$joinfield}";
    }
    if ($filter) {
        $query .= " WHERE {$filter}";
    }
    $result = mysqli_query($conn, $query);
    $nrcampos = mysqli_field_count($conn);
    echo "<h2>{$title}</h2>";
    echo "{$dbtable}";
    if ($dbjoin) {
        echo "| <a href=\"dbshow.php?dbtable={$dbjoin}\" target=\"_blank\">{$dbjoin}</a>";
    }
    echo "| " . mysqli_num_rows($result) . " row(s)";
    echo "<p><table cellspacing=\"0\" cellpadding=\"5\" border=\"1\">";
    echo "<tr>";
    for ($i = 0; $i < $nrcampos; $i++) {
        $finfo = mysqli_fetch_field_direct($result, $i);
        echo "<td>" . $finfo->name . "</td>";
    }
    echo "</tr>";
    while ($row = mysqli_fetch_array($result)) {
        echo "<tr>";
        for ($i = 0; $i < $nrcampos; $i++) {
            echo "<td>" . $row[$i] . "</td>";
        }
        echo "</tr>";
    }
    echo "</table></p><br>&nbsp;";
}
开发者ID:jmendonca73,项目名称:caramba,代码行数:33,代码来源:dbshow+-+Copy.php

示例7: verificar_login

function verificar_login($userid, $pass, &$result)
{
    $servername = "localhost";
    $username = 'root';
    $password = "";
    $dbname = "cmd";
    // Create connection
    $conn = new mysqli($servername, $username, $password, $dbname);
    // Check connection
    if ($conn->connect_error) {
        die("Connection failed: " . $conn->connect_error);
    }
    $sql = "SELECT * FROM `trabajador` WHERE `userid`=\"" . $userid . "\" and `password`=\"" . $pass . "\"";
    $result = mysqli_query($conn, $sql);
    $count = 0;
    if (!$result) {
        echo "no result";
    } else {
        if (mysqli_num_rows($result) > 0) {
            while ($row = mysqli_fetch_assoc($result)) {
                $_SESSION['userid'] = $row["userid"];
                $_SESSION['rol'] = $row["rol"];
                $count++;
            }
        }
        if ($count == 1) {
            return 1;
        } else {
            return 0;
        }
    }
}
开发者ID:AGonzalezMaillard,项目名称:CMDashboard,代码行数:32,代码来源:index.php

示例8: getCount

 public function getCount($sql, $row = 0, $field = null)
 {
     $query = $this->execute_sql($sql);
     is_object($query) and mysqli_num_rows($query) and $result = $this->fetch_one($query, $row, $field) or $result = 0;
     $this->free_result();
     return $result;
 }
开发者ID:huangbinzd,项目名称:kppwGit,代码行数:7,代码来源:mysqli_driver.php

示例9: buscar

    function buscar($dato)
    {
        $sql = "select * \r\n\t\t\tfrom ot\r\n\t\t\twhere folio like '%" . $dato . "%' OR nombre like '%" . $dato . "%' OR modelo like '%" . $dato . "%' OR serie like '%" . $dato . "%' ";
        $rs = mysqli_query($this->conn, $sql);
        $i = 0;
        if (mysqli_num_rows($rs) < 1) {
            echo "La busqueda no obtuvo resultados.";
        } else {
            echo "<table border='1' align='center' class='table_' ><thead>\r\n\t\t\t\t\t<th>Folio</th>\r\n\t\t\t\t\t<th>Nombre</th>\r\n\t\t\t\t\t<th>Apellido</th>\r\n\t\t\t\t\t<th>Modelo</th>\r\n\t\t\t\t\t<th>Serie</th>\r\n\t\t\t\t\t<th>descripcion</th>\r\n\t\t\t\t\t<th>Fallas</th>\r\n\t\t\t\t\t<th>Resultado</th>\r\n\t\t\t\t\t<th>Estatus</th>\r\n\t\t\t\t\t<th>Fecha_Reg</th>\r\n\t\t\t\t\t<th>Fecha_Entr</th>\r\n\t\t\t\t\t<th>Comentario</th>\r\n\t\t\t\t</thead><tbody>";
            while ($row = mysqli_fetch_array($rs)) {
                echo "<tr><td align='center'>" . $row["folio"] . "</td>";
                echo "<td align='center'>" . $row["nombre"] . "</td>";
                echo "<td align='center'>" . $row["apellido"] . "</td>";
                echo "<td align='center'>" . $row["modelo"] . "</td>";
                echo "<td align='center'>" . $row["serie"] . "</td>";
                echo "<td align='center'>" . $row["des"] . "</td>";
                echo "<td align='center'>" . $row["fallas"] . "</td>";
                echo "<td align='center'>" . $row["resultado"] . "</td>";
                echo "<td align='center'>" . $row["estatus"] . "</td>";
                echo "<td align='center'>" . $row["fechae"] . "</td>";
                echo "<td align='center'>" . $row["fecha"] . "</td>";
                echo '<td align="center">
			<a class="fancybox fancybox.iframe" href="index.php?id=' . $row["id"] . '&folio=' . $row["folio"] . '&nombre=' . $row["nombre"] . '&apellido=' . $row["apellido"] . '&telefono=' . $row["telefono"] . ' " >Comentario</a></td>';
                $i++;
            }
        }
        echo "</tbody></table>";
    }
开发者ID:alejandro0892,项目名称:mi_web,代码行数:28,代码来源:modelo_clie.php

示例10: storeUser

 /**
  * Storing new user
  * returns user details
  */
 public function storeUser($name, $email, $gcm_regid)
 {
     // insert user into database
     $c = new DB_Connect();
     $d = $c->connect();
     $test = mysqli_query($d, "SELECT * class_details where code='{$email}'");
     if ($test) {
         $result = mysqli_query($d, "INSERT INTO gcm_users(name, email, gcm_regid, created_at) VALUES('{$name}', '{$email}', '{$gcm_regid}', NOW())");
         // check for successful store
         if ($result) {
             // get user details
             $id = mysqli_insert_id();
             // last inserted id
             $result = mysqli_query($d, "SELECT * FROM gcm_users WHERE id = {$id}") or die(mysql_error());
             // return user details
             if (mysqli_num_rows($result) > 0) {
                 return mysqli_fetch_array($result);
             } else {
                 return false;
             }
         } else {
             return false;
         }
     } else {
         return false;
     }
 }
开发者ID:nilesh95,项目名称:project,代码行数:31,代码来源:db_functions+(1).php

示例11: deleteInstitution

function deleteInstitution($institutionId)
{
    //Delete all children of Institution
    $conn = connectToDatabase();
    mysqli_begin_transaction($conn, MYSQLI_TRANS_START_READ_WRITE);
    $sql = "SELECT CURP FROM BelongsToInstitution WHERE institutionId = '{$institutionId}';";
    $result = mysqli_query($conn, $sql);
    if (mysqli_num_rows($result) > 0) {
        while ($row = mysqli_fetch_assoc($result)) {
            deleteChildSameConnection($row["CURP"], $conn);
        }
    }
    //Delete all users from institution
    $sql = "SELECT userName FROM WorksInInstitution WHERE institutionId = '{$institutionId}';";
    $result = mysqli_query($conn, $sql);
    if (mysqli_num_rows($result) > 0) {
        while ($row = mysqli_fetch_assoc($result)) {
            deleteUserSameConnection($row["userName"], $conn);
        }
    }
    $sql = "DELETE FROM Institution WHERE institutionId = '{$institutionId}'";
    if (mysqli_query($conn, $sql)) {
        echo "1";
    } else {
        echo "0" . mysqli_error($conn);
    }
    mysqli_commit($conn);
    closeDb($conn);
}
开发者ID:EduardoVaca,项目名称:KidsMatter,代码行数:29,代码来源:deletes.php

示例12: retourneDevoirs

function retourneDevoirs($ele_login)
{
    $date_ct1 = mktime(0, 0, 0, date("m"), date("d"), date("Y"));
    // On récupère tous les devoirs depuis aujourd'hui 00:00:00
    $sql = "SELECT DISTINCT ctde.* FROM ct_devoirs_entry ctde, j_eleves_groupes jeg\r\n\t\t\t\t\t\t\t\tWHERE ctde.id_groupe = jeg.id_groupe\r\n\t\t\t\t\t\t\t\tAND jeg.login = '" . $ele_login . "'\r\n\t\t\t\t\t\t\t\tAND ctde.date_ct >= '" . $date_ct1 . "'\r\n\t\t\t\t\t\t\tORDER BY ctde.date_ct, ctde.id_groupe;";
    //echo "$sql<br />";
    $res_ct = mysqli_query($GLOBALS["mysqli"], $sql);
    $cpt2 = 0;
    // on initialise un compteur pour le while
    if (mysqli_num_rows($res_ct) > 0) {
        while ($lig_ct = mysqli_fetch_object($res_ct)) {
            $tab_ele['cdt_dev'][$cpt2] = array();
            $tab_ele['cdt_dev'][$cpt2]['id_ct'] = $lig_ct->id_ct;
            $tab_ele['cdt_dev'][$cpt2]['id_groupe'] = $lig_ct->id_groupe;
            $tab_ele['cdt_dev'][$cpt2]['date_ct'] = $lig_ct->date_ct;
            $tab_ele['cdt_dev'][$cpt2]['id_login'] = $lig_ct->id_login;
            $tab_ele['cdt_dev'][$cpt2]['contenu'] = $lig_ct->contenu;
            $cpt2++;
        }
        $tab_ele['cdt_dev']['count'] = $cpt2;
    } else {
        $tab_ele['cdt_dev']['count'] = 0;
    }
    return $tab_ele;
}
开发者ID:rhertzog,项目名称:lcs,代码行数:25,代码来源:fonctions_cdt.inc.php

示例13: validate

function validate($dbc, $email = '', $pwd = '')
{
    $errors = array();
    #Array to store errors.
    if (empty($email)) {
        $errors[] = 'Enter your email address.';
    } else {
        $e = mysqli_real_escape_string($dbc, trim($email));
        #Escapes any special characters
        #to avoid codes being run on the database.
        $email = strip_tags($email);
    }
    if (empty($pwd)) {
        $errors[] = 'Enter your password.';
    } else {
        $p = mysqli_real_escape_string($dbc, trim($pwd));
        $pwd = strip_tags($pwd);
    }
    if (empty($errors)) {
        $q = "SELECT customer_id,first_name,last_name\r\n\tFROM customers \r\n\tWHERE email='{$e}'\r\n\tAND password= SHA1('{$p}')";
        #Retrieves customer related data
        $r = mysqli_query($dbc, $q);
        if (mysqli_num_rows($r) == 1) {
            $row = mysqli_fetch_array($r, MYSQLI_ASSOC);
            return array(true, $row);
        } else {
            $errors[] = 'Email address and password not found';
        }
        return array(false, $errors);
    }
}
开发者ID:amoking,项目名称:ebook_store,代码行数:31,代码来源:login_tools.php

示例14: getDatosAnteriores

function getDatosAnteriores($nombreUsuario)
{
    $datos = array();
    if ($connect = mysqli_connect("localhost", "root", "", "prueba1")) {
        $sql_select = sprintf("select Nombre,Apellidos,Fecha_Nacimiento,DNI,Localidad,Provincia,CP,Telefono from datos_usuarios\r\n\t\t\t\t\t\t\tinner join credenciales on datos_usuarios.ID_Credenciales=credenciales.idCredenciales\r\n\t\t\t\t\t\t\twhere credenciales.Usuario= '%s';", $nombreUsuario);
        //echo $sql_select."</br>";
        $resultado_queryDatos = mysqli_query($connect, $sql_select);
        if ($resultado_queryDatos == FALSE) {
            echo "Error al ejecutar la consulta:</br>";
            echo mysqli_error($resultado_queryDatos) . "</br>";
        } else {
            if (mysqli_num_rows($resultado_queryDatos) == 1) {
                $i = 0;
                $registro = mysqli_fetch_row($resultado_queryDatos);
                while ($i <= 7) {
                    //echo $i." ".$registro[$i]."</br>";
                    $datos[$i] = $registro[$i];
                    $i++;
                }
                return $datos;
            } else {
                echo "El resultado es diferente uno";
                return false;
            }
        }
    } else {
        echo "Error al conectar con BBDD </br>";
        return false;
    }
}
开发者ID:luicabpar,项目名称:webPrueba,代码行数:30,代码来源:modificar_datos.php

示例15: change_forgot_password

/**
* смена пароля
**/
function change_forgot_password()
{
    global $connection;
    $hash = trim(mysqli_real_escape_string($connection, $_POST['hash']));
    $password = trim($_POST['new_password']);
    if (empty($password)) {
        $_SESSION['forgot']['change_error'] = "Не введен пароль";
        return;
    }
    $query = "SELECT * FROM forgot WHERE hash = '{$hash}' LIMIT 1";
    $res = mysqli_query($connection, $query);
    // если не найден хэш
    if (!mysqli_num_rows($res)) {
        return;
    }
    $now = time();
    $row = mysqli_fetch_assoc($res);
    // если ссылка устарела
    if ($row['expire'] - $now < 0) {
        mysqli_query($connection, "DELETE FROM forgot WHERE expire < {$now}");
        return;
    }
    $password = md5($password);
    mysqli_query($connection, "UPDATE users SET password = '{$password}' WHERE email = '{$row['email']}'");
    mysqli_query($connection, "DELETE FROM forgot WHERE email = '{$row['email']}'");
    $_SESSION['forgot']['ok'] = "Вы успешно сменили пароль. Теперь можно авторизоваться";
}
开发者ID:dimonoov,项目名称:catalog.loc,代码行数:30,代码来源:forgot_model.php


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