本文整理汇总了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;
}
示例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;
}
示例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']);
示例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';
}