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


PHP mysqli::fetch_assoc方法代码示例

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


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

示例1: loadFromMysqliResult

 /**
  * Load from mysqli result
  *
  * @return bool
  */
 protected function loadFromMysqliResult()
 {
     $this->currentData = null;
     if (($data = $this->resource->fetch_assoc()) === null) {
         return false;
     }
     $this->position++;
     $this->currentData = $data;
     $this->currentComplete = true;
     $this->nextComplete = true;
     $this->position++;
     return true;
 }
开发者ID:musicsnap,项目名称:Yaf.Global.Library,代码行数:18,代码来源:Result.php

示例2: create_table

/**
 * @param mysqli $result  le pasamos el resultado de la consulta de la base de datos.
 * @param array $col_names, array de strings que tiene como valor por defecto un array vacio, si está vacio los nombres de las columnas serán los nombres de las columnas de la base de datos, si queremos darles nombres mas representativos podemos rellenar este campo (ej['nombre','apellido','email'])
 * @return string $table devuelve el string formado que contiene la tabla
 */
function create_table($result, $col_names = array())
{
    // echo count($col_names).'<br>';
    $table = '';
    $rows = array();
    while ($row = $result->fetch_assoc()) {
        array_push($rows, $row);
    }
    $table .= '<table class="table table-bordered table-hover">';
    $table .= '<tr class="info">';
    if (count($col_names) !== 0) {
        for ($i = 0; $i < count($col_names); $i++) {
            $table .= ' <th>' . $col_names[$i] . '</th>';
        }
    } else {
        foreach ($rows as $row) {
            $count = 0;
            foreach ($row as $key => $value) {
                $table .= ' <th>' . $key . '</th>';
                if ($count > count($row)) {
                    break;
                }
                $count++;
            }
            break;
        }
    }
    $table .= '</tr>';
    foreach ($rows as $row) {
        $table .= '<tr>';
        foreach ($row as $key => $value) {
            $table .= ' <td>' . $value . '</td>';
        }
        $table .= '</tr>';
    }
    $table .= '</table>';
    return $table;
}
开发者ID:kiviev,项目名称:facturas,代码行数:43,代码来源:fnc.php

示例3: mysqli

}
//------
// First of all, check to see whether the user is browsing with a mobile device.
include __DIR__ . '/../mobile_devices.php';
// Get the list of mobile devices. Set $mobile to true if the visitor is using a device from this list.
if (false) {
    $mysqli = new mysqli("secrethost", "secretuser", "secretpassword", "Accounts");
    // Connect to the database.
    // Check to see if the user is not yet logged in.
    if (!isset($_SESSION['username']) || !isset($_SESSION['id'])) {
        // If he is not yet logged in, check to see if he has just now submitted his login information.
        // If he has just now logged in, then verify that his login information is valid.
        if (!isset($_POST['login']) && $mobile == true) {
            $visitor = $mysqli->query("SELECT * FROM Members\n\t\t\tWHERE ip='" . $_SERVER['REMOTE_ADDR'] . "'");
            $x = 0;
            while ($row = $mysqli->fetch_assoc($visitor)) {
                if ($row['logged_in'] == true) {
                    $x++;
                    // If $x == 1, start a session.
                    // If $x == 2, too many people are logged in through the same IP address. Log them all out and end the session.
                    // If $x >= 2, too many people are logged in through the same IP address. Log the account on this loop out.
                    if ($x == 1) {
                        session_start();
                        $_SESSION['id'] = $row['id'];
                        $_SESSION['username'] = $row['username'];
                    } elseif ($x == 2) {
                        logout($row['id']);
                        $err = "mult_log";
                    }
                    if ($x >= 2) {
                        $mysqli->query("UPDATE Members SET logged_in = 0\n\t\t\t\t\t\tWHERE id = " . $row['id']);
开发者ID:CarterNelms,项目名称:www.engineeredcomfort.net,代码行数:31,代码来源:head.php

示例4: mysqli

#
#  Visit the openSIS web site at http://www.opensis.com to learn more.
#  If you have question regarding this system or the license, please send
#  an email to info@os4ed.com.
#
#  This program is released under the terms of the GNU General Public License as
#  published by the Free Software Foundation, version 2 of the License.
#  See license.txt.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
#***************************************************************************************
error_reporting(0);
session_start();
$_SESSION['admin_name'] = $_POST['auname'];
$_SESSION['admin_pwd'] = md5($_POST['apassword']);
$dbconn = new mysqli($_SESSION['host_mod'], $_SESSION['username'], $_SESSION['password'], $_SESSION['db']);
if (isset($_REQUEST['username']) && $_REQUEST['username'] != '') {
    $result_username = $dbconn->fetch_assoc($dbconn->query('SELECT COUNT(1) as USERNAME_EX FROM login_authentication WHERE USERNAME=\'' . $_REQUEST['username'] . '\''));
}
if ($result_username['USERNAME_EX'] == 0) {
    echo '0';
} else {
    echo '1';
}
开发者ID:jeffthestampede,项目名称:excelsior,代码行数:31,代码来源:UsernameCheckOthers.php


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