本文整理汇总了PHP中mysqli_fetch_row函数的典型用法代码示例。如果您正苦于以下问题:PHP mysqli_fetch_row函数的具体用法?PHP mysqli_fetch_row怎么用?PHP mysqli_fetch_row使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mysqli_fetch_row函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: check_id
function check_id($conn, $uid)
{
$sql = "select count(*) from users where uid = {$uid}";
$result = mysqli_query($conn, $sql);
$row = mysqli_fetch_row($result);
return !$row[0];
}
示例2: display_view
function display_view()
{
$con = mysqli_connect('localhost', 'root', '');
$db = mysqli_select_db($con, 'stats');
$query = "SELECT s.Year, t.team_name FROM season s, team t where s.winner_team_id = t.team_id";
$result = mysqli_query($con, $query);
if ($result) {
$row = mysqli_fetch_row($result);
echo '<table border="1" style= "text-align: center; color: #092f44; margin: 0 auto;" >';
echo '<tr> <th>Season Year</th>
<th>Winner Team</th>
</tr>';
while ($row) {
$col = count($row);
echo "<tr>";
for ($c = 0; $c < $col; $c++) {
echo "<td>" . $row[$c] . "</td>";
}
echo "</tr>";
$row = mysqli_fetch_row($result);
}
echo "</table>";
} else {
echo "err";
}
}
示例3: 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');
}
示例4: getAttribute
public function getAttribute($attribute, &$source = null, $func = 'PDO::getAttribute', &$last_error = null)
{
if ($source == null) {
$source =& $this->driver_options;
}
switch ($attribute) {
case PDO::ATTR_AUTOCOMMIT:
$result = mysqli_query($this->link, 'SELECT @@AUTOCOMMIT', MYSQLI_USE_RESULT);
if (!$result) {
$this->set_driver_error(null, PDO::ERRMODE_EXCEPTION, $func);
}
$row = mysqli_fetch_row($result);
mysqli_free_result($result);
return intval($row[0]);
break;
case PDO::ATTR_CLIENT_VERSION:
return mysqli_get_client_info();
break;
case PDO::ATTR_CONNECTION_STATUS:
return mysqli_get_host_info($this->link);
break;
case PDO::ATTR_SERVER_INFO:
return mysqli_stat($this->link);
break;
case PDO::ATTR_SERVER_VERSION:
return mysqli_get_server_info($this->link);
break;
default:
return parent::getAttribute($attribute, $source, $func, $last_error);
break;
}
}
示例5: addApplicant
function addApplicant(Applicant $applicant)
{
$connectionObject = Connection::getInstance();
$connection = $connectionObject->get_connection();
$name_in_full = $applicant->getNameInFull();
$name_with_initials = $applicant->getNameWithInitials();
$nic = $applicant->getNic();
$is_sri_lankan = $applicant->getIsSriLankan();
$religion = $applicant->getReligion();
$address = $applicant->getAddress();
$telephone = $applicant->getTelephone();
$district = $applicant->getDistrict();
$divisional_sec_area = $applicant->getDivisionalSecArea();
$grama_niladari_divi = $applicant->getGramaNiladariDivi();
$sql = "SELECT \tapplicant_id FROM applicant WHERE nic = '" . $nic . "'";
$resultset = mysqli_query($connection, $sql);
$numberOfRows = mysqli_num_rows($resultset);
if ($numberOfRows > 0) {
$row = mysqli_fetch_row($resultset);
$applicant_id = $row[0];
} else {
$stmt = $connection->prepare("INSERT INTO applicant (name_in_full, name_with_initials, nic, religion, address, is_sri_lankan, district, divisional_sec_area, grama_niladari_divi,telephone) VALUES (?,?,?,?,?,?,?,?,?,?)");
$stmt->bind_param("ssssssssss", $name_in_full, $name_with_initials, $nic, $religion, $address, $is_sri_lankan, $district, $divisional_sec_area, $grama_niladari_divi, $telephone);
$result = $stmt->execute();
$stmt->close();
$applicant_id = mysqli_insert_id($connection);
}
return $applicant_id;
}
示例6: Select
public function Select()
{
$a = null;
$sql = "select * from publishednews";
if ($this->PublisherId > 0) {
$sql .= " where PublisherId = " . $this->PublisherId;
}
$r = mysqli_query($this->cn, $sql);
while ($s = mysqli_fetch_row($r)) {
$item = new publishednews();
$item->NewsId = $s[0];
$item->PublisherId = $s[1];
$item->Date = $s[2];
include_once 'Model/news.php';
$item->News = new News();
$item->News->Id = $item->NewsId;
$item->News->SelectById();
include_once 'Model/user.php';
$item->Publisher = new User();
$item->Publisher->Id = $item->PublisherId;
$item->Publisher->SelectById();
$a[] = $item;
}
return $a;
}
示例7: getInfo
function getInfo($element, $sharer_id, $conx)
{
$sql = "SELECT {$element} FROM table_userinfo WHERE id='{$sharer_id}' AND activated='1' LIMIT 1";
$query = mysqli_query($conx, $sql);
$info = mysqli_fetch_row($query);
return "{$info['0']}";
}
示例8: LoadGraph
public function LoadGraph($id)
{
$tableid = $id;
if ($id > 12) {
$id = $id % 12;
}
$query = "select date, OilLevel{$id}, OilAlarmLevel{$id}, GasLevel{$id}, GasAlarmLevel{$id} from detector{$tableid}";
if ($result = mysqli_query($this->link, $query)) {
$fp = fopen("datafiles/detector{$tableid}.csv", "w");
/* fetch associative array */
while ($row = mysqli_fetch_row($result)) {
if ($row[1] > 100) {
$row[1] = 100;
}
if ($row[2] > 100) {
$row[2] = 100;
}
if ($row[3] > 100) {
$row[3] = 100;
}
if ($row[4] > 100) {
$row[4] = 100;
}
fwrite($fp, implode(',', $row) . "\n");
}
/* free result set */
mysqli_free_result($result);
// echo json_encode(array("demo"=>$returnArray));
}
}
示例9: sqllogin
function sqllogin($host, $dbuser, $dbpass, $dbname)
{
// connectivity
//mysql connections for stacked query examples.
$con1 = mysqli_connect($host, $dbuser, $dbpass, $dbname);
$username = mysqli_real_escape_string($con1, $_POST["login_user"]);
$password = $_POST["login_password"];
// Check connection
if (mysqli_connect_errno($con1)) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
} else {
@mysqli_select_db($con1, $dbname) or die("Unable to connect to the database ######: ");
}
/* execute multi query */
$sql = "SELECT * FROM users WHERE username='{$username}' and password='{$password}'";
if (@mysqli_multi_query($con1, $sql)) {
/* store first result set */
if ($result = @mysqli_store_result($con1)) {
if ($row = @mysqli_fetch_row($result)) {
if ($row[1]) {
return $row[1];
} else {
return 0;
}
}
}
}
}
示例10: check_login
function check_login($user_id, $password)
{
session_destroy();
session_start();
$moodle_host = "127.0.0.1";
$moodle_port = "3306";
$moodle_user = "root";
$moodle_db = "moodle";
$moodle_pass = "";
$moodle_conn = mysql_connect($moodle_host . ":" . $moodle_port, $moodle_user, $moodle_pass);
$moodle_salt = '-Y9-h0;),c@<i)D~*i/j7.pD6lh/,B';
$password = md5($password . $moodle_salt);
$ret = false;
$moodle_pre = "mdl_";
$sql = "select password from " . $moodle_pre . "user where username='" . mysqli_real_escape_string($mysqli, $user_id) . "'";
if ($moodle_conn) {
mysql_select_db($moodle_db, $moodle_conn);
$result = mysqli_query($mysqli, $sql, $moodle_conn);
$row = mysqli_fetch_row($result);
if ($row && $password == $row[0]) {
$ret = $user_id;
}
}
return $ret;
}
示例11: login
function login()
{
global $emailid1, $pass1;
$con = mysqli_connect('localhost', 'root', '');
$db = mysqli_select_db($con, 'accommodation');
$query = "SELECT email_id, pass FROM property_manager WHERE email_id='{$emailid1}'";
$result = mysqli_query($con, $query);
$num = mysqli_num_rows($result);
$row = mysqli_fetch_array($result);
if ($num == 0) {
echo "Property Manager Doesn't Exist";
} else {
if ($pass1 == $row['pass']) {
$q2 = "SELECT id FROM property_manager WHERE email_id='{$emailid1}'";
$result = mysqli_query($con, $q2);
$row = mysqli_fetch_row($result);
$id1 = $row[0];
session_start();
$_SESSION["id_1"] = $id1;
header('location: pm_home.php');
} else {
echo "Incorrect Password";
}
}
}
示例12: search_results1
function search_results1($name1)
{
$link = mysqli_connect("localhost", "root", "", "db1");
$returned_result = array();
$where = "";
$name1 = preg_split('/[\\s]/', $name1);
$total = count($name1);
foreach ($name1 as $key => $keywords) {
$where .= "`desc` LIKE '%{$keywords}%'";
if ($key != $total - 1) {
$where .= " AND ";
}
}
$result = "select * from `collect` where {$where}";
$res1 = mysqli_query($link, $result);
$b = ".jpg";
if (mysqli_num_rows($res1) === 0) {
echo "<h3 color='#1cff33'>Nothing Found!!!</h3><br><br><br><br><br><br><br><br><br><br><br>";
} else {
while ($res = mysqli_fetch_row($res1)) {
$d = "{$res['4']}" . "{$b}";
echo "<table class=\"one\" cellspacing=\"1px\">\n <tr>\n <td align=\"center\">\n <img class=\"one\" src='./product/electronics/{$d}' />\n </td>\n </tr>\n <tr>\n <p>\n <td align=\"center\">\n ";
echo "<p><a href=\"#\" class=\"five\">\n<font color=\"#a20099\" size=\"6\"><br>{$res['2']}\n<br>\n</a>\n</font>\n<br />\n<font color=\"cc1100\" size=\"6\">\n<b>Rs.{$res['3']}</b>\n<hr />\n</font>\n</td>\n</tr>\n</table>";
}
}
echo "</div>";
}
示例13: DisplayTableInHTML
function DisplayTableInHTML($table_name)
{
global $db;
// refer to the global variable 'db'
$query = "SELECT * FROM " . $table_name;
$res = $db->query($query);
// yes, just like this
if (!$res) {
exit("There is a MySQL error, exiting this script");
}
echo "<p style=\"text-align:center; background-color:#FAEBD7; margin-top: 10px\">Table " . $table_name . "<br></p>";
// dynamic HTML table
echo "<table border=\"1px\" class=\"admin_table table table-striped table-hover\" style=\"border-collapse: collapse\">";
echo "<thead>";
echo "<tr><th>Graph ID</th>";
echo "<th>User ID</th>";
echo "<th>Best Score</th>";
echo "</tr>";
echo "</thead>";
while ($r = mysqli_fetch_row($res)) {
// important command
echo "<tr><td>" . $r[0] . "</td>";
// echo first column
for ($i = 1; $i < count($r); $i++) {
echo "<td>" . $r[$i] . "</td>";
}
echo "</tr>";
}
echo "</table>";
}
示例14: signup
function signup()
{
global $id1, $emailid1, $pass1;
$con = mysqli_connect('localhost', 'root', '');
$db = mysqli_select_db($con, 'accommodation');
$query = "SELECT * FROM property_manager WHERE email_id = '{$emailid1}'";
$result = mysqli_query($con, $query);
$num = mysqli_num_rows($result);
if ($num != 0) {
echo "EmailID already exists";
} else {
$query = "INSERT INTO property_manager (`email_id`, `pass`) VALUES ('{$emailid1}','{$pass1}')";
if (!$con->query($query)) {
echo "INSERT failed";
} else {
$q2 = "SELECT id FROM property_manager WHERE email_id='{$emailid1}'";
$result = mysqli_query($con, $q2);
$row = mysqli_fetch_row($result);
$id1 = $row[0];
session_start();
$_SESSION["id_1"] = $id1;
header('location: pm_home.php');
}
}
}
示例15: listDbData
function listDbData()
{
$link = mysqli_connect('localhost', 'root', '') or die(mysql_error());
$db_list = mysql_list_dbs($link);
print "<table width=100% bgcolor='BLACK' cellspacing=1 cellpadding=0>";
print "<tr bgcolor=#BBBBBB><td align='center'>";
print "<b>Database list</b>";
print "</td></tr>";
while ($row = mysqli_fetch_object($link, $db_list)) {
print "<tr bgcolor='WHITE'><td align='center'>";
print $row->Database;
//echo $row->Database . "<br>";
print "</td></tr>";
}
print "<tr bgcolor=#BBBBBB><td align='center'>";
print "<b>Tables</b>";
print "</td></tr>";
$db_selected = mysqli_select_db('maxinedb', $link);
$sql = "SHOW TABLES";
$result = mysqli_query($link, $sql);
if (!$result) {
throw new man_exception('MySQL Error: ' . mysql_error());
}
while ($row = mysqli_fetch_row($link, $result)) {
print "<tr bgcolor='WHITE'><td align='center'>";
print $row[0] . "";
print "</td></tr>";
}
print "</table>";
}