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


PHP num_rows函数代码示例

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


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

示例1: create_account

    function create_account()
    {
        if ($this->user['type'] != 1) {
            return 0;
        }
        if (strlen($_REQUEST['name']) < 2) {
            $this->html['shipon_account_output'] = "Name is too short.";
        } elseif (strlen($_REQUEST['username']) < 4) {
            $this->html['shipon_account_output'] = "Username must be at least 4 characters (" . strlen($_REQUEST['username']) . ").";
        } elseif (strlen($_REQUEST['password']) < 6) {
            $this->html['shipon_account_output'] = "Password must be at least 6 characters.";
        } else {
            $users_result = query("SELECT id FROM `" . $this->user['database'] . "`.accounts WHERE username=?", array($_REQUEST['username']));
            if (num_rows($users_result) < 1) {
                $id = query_r("INSERT INTO `" . $this->user['database'] . "`.accounts\n\t\t\t\t\t\t\t   (\n\t\t\t\t\t\t\t\t\t\tgroup_id, name, phone, ext, email, username, password, type\n\t\t\t\t\t\t\t   )\n\t\t\t\t\t\t\t   VALUES\n\t\t\t\t\t\t\t   (\n\t\t\t\t\t\t\t\t\t'" . $this->user['group'] . "', ?, ?, ?, ?, ?, ?, 2\n\t\t\t\t\t\t\t   )\n\t\t\t\t\t\t\t", array($_REQUEST['name'], $_REQUEST['phone'], $_REQUEST['ext'], $_REQUEST['email'], $_REQUEST['username'], md5($_REQUEST['password'])));
                query("INSERT INTO `" . $this->user['database'] . "`.sessions\n\t\t\t\t\t\t(\n\t\t\t\t\t\t\tid, session_id, timestamp\n\t\t\t\t\t\t)\n\t\t\t\t\t\tVALUES\n\t\t\t\t\t\t(\n\t\t\t\t\t\t\t'" . $id . "','0','0'\n\t\t\t\t\t\t)\n\t\t\t\t\t");
                $this->html['shipon_account_output'] = '<script type="text/javascript">
                                                                            jQuery("#shipon_account_popup").dialog("close");
                                                                            change_view("manage_accounts");
									</script>';
            } else {
                $this->html['shipon_account_output'] = "User already exists.";
            }
        }
    }
开发者ID:kamalspalace,项目名称:_CORE,代码行数:25,代码来源:account_manager.php

示例2: links

function links($cat = 0, $direction = "asc")
{
    global $linksmessage, $prefix;
    if ($direction != "asc" && $direction != "desc") {
        $direction = "asc";
    }
    $out = "";
    if ($cat) {
        $query = "SELECT * FROM " . $prefix . "linkscat WHERE id=" . $cat . " ORDER BY nome";
    } else {
        $query = "SELECT * FROM " . $prefix . "linkscat ORDER BY nome";
    }
    if (!($cresult = dbquery($query))) {
        die($linksmessage[4]);
    }
    $out .= "\n<div id=\"LNE_show\">\n";
    while ($crow = fetch_array($cresult)) {
        $out .= "<h3>" . decode($crow['descr']) . "</h3>\n";
        $query = "SELECT * FROM " . $prefix . "links where hits=" . $crow[0] . " ORDER BY name " . $direction;
        if (!($result = dbquery($query))) {
            die($linksmessage[5]);
        }
        if (num_rows($result)) {
            $out .= "<ul>\n";
            while ($row = fetch_array($result)) {
                $out .= "<li><a href=\"" . $row['link'] . "\" onclick=\"window.open(this.href,'_blank');return false;\">" . decode($row['name']) . "</a><div>" . decode($row['descr']) . "</div></li>\n";
            }
            $out .= "</ul>\n";
        }
    }
    $out .= "</div>\n";
    return $out;
}
开发者ID:squidjam,项目名称:LightNEasy,代码行数:33,代码来源:main.php

示例3: get_news

/**
 * returns $number news items from class $type
 */
function get_news($type, $number)
{
    $news = "SELECT `ID`, `timestamp`, `subject`, `body` FROM `news` WHERE `class`='{$type}' ORDER BY `ID` DESC LIMIT {$number}";
    connect_sql();
    $news = @query($news) or die("Error getting the news.");
    // see if we don't have any news
    if (num_rows($news) == 0) {
        return "No news.";
    } else {
        $to_return = "";
        while ($row = result($news)) {
            $id = $row->ID;
            $timestamp = $row->timestamp;
            $subject = stripslashes($row->subject);
            $body = $row->body;
            // convert line breaks to <br />'s
            $body = str_replace("\\r\\n", "<br />", $body);
            // for windows and IP protocols
            $body = str_replace("\\n", "<br />", $body);
            // for nix
            $body = str_replace("\\r", "<br />", $body);
            // for mac
            $body = stripslashes($body);
            $to_return .= $id . "::::" . $timestamp . "::::" . $subject . "::::" . $body . "_____";
        }
        return $to_return;
    }
    disconnect_sql();
}
开发者ID:kfr2,项目名称:phpmygrades,代码行数:32,代码来源:newslib.php

示例4: get_numrows

function get_numrows($sql)
{
    $result = query($sql);
    $rowlist = num_rows($result);
    mysql_free_result($result);
    return $rowlist;
}
开发者ID:lilili001,项目名称:think,代码行数:7,代码来源:mysql.php

示例5: init

 function init($data)
 {
     $history_xml = file_get_contents($this->user['folder'] . "/templates/history.xml");
     $xml = new SimpleXMLElement($history_xml);
     $req = array();
     $req['entries_per_page'] = 10;
     $req['search_string'] = isset($_REQUEST['search_string']) && $_REQUEST['search_string'] != 'Search' ? $_REQUEST['search_string'] : '';
     $req['sort_column'] = isset($_REQUEST['sort_by']) ? $_REQUEST['sort_by'] : 'id';
     $req['sort_order'] = isset($_REQUEST['sort_order']) ? $_REQUEST['sort_order'] : 'DESC';
     $req['start_row'] = isset($_REQUEST['data']) ? $_REQUEST['data'] * 10 + 1 : 1;
     $req['bill_to_code'] = $this->user['bill_to_code'];
     $search_string = "1";
     $s = "";
     $var_array = array();
     $fieldString = "id,ext_id,cons_name,sent,timestamp";
     if (isset($_REQUEST['search_string']) && $_REQUEST['search_string'] != "Search") {
         $s = $_REQUEST['search_string'];
         $search_string = "(id LIKE ? OR bill_id LIKE ? OR timestamp LIKE ? OR cons_name LIKE ?)";
         $var_array = array("%" . $s . "%", "%" . $s . "%", "%" . $s . "%", "%" . $s . "%");
     }
     $sort_by = 'id';
     if (isset($_REQUEST['sort_by'])) {
         $sort_by = $xml->content->column[(int) $_REQUEST['sort_by']]['key'];
     } else {
         $_REQUEST['sort_by'] = '0';
     }
     if (!isset($_REQUEST['sort_order'])) {
         $_REQUEST['sort_order'] = "DESC";
     }
     $history_result = query("SELECT " . $fieldString . " FROM `" . $this->user['database'] . "`.shipments\n\t\t\t\t\t\t\t\tWHERE group_id='" . $this->user['group'] . "' AND " . $search_string . " AND ext_id > 0 ORDER BY " . $sort_by . " " . $_REQUEST['sort_order'] . " \n\t\t\t\t\t\t\t\t LIMIT " . $data * $xml->entries_per_page . "," . $xml->entries_per_page, $var_array);
     $result_count = num_rows($history_result);
     $num_result = query("SELECT id FROM `" . $this->user['database'] . "`.shipments WHERE group_id='" . $this->user['group'] . "' AND " . $search_string . "  AND ext_id > 0", $var_array);
     $num = num_rows($num_result);
     $pageCount = ceil($num / $xml->entries_per_page);
     //	$titlebar_inputs =  "<input type='text' class='shipon_input' id='shipon_history_search' value='Search'>";
     //	$history = $this->get_field_header('100%', 'history', $titlebar_inputs);
     for ($i = 0; $i < $xml->entries_per_page; $i++) {
         if ($i < $result_count) {
             $shipment[] = fetch($history_result);
         }
     }
     $history .= $this->get_paged_footer("#history", $xml->entries_per_page, $pageCount, $xml->page_numbers);
     if (isset($_REQUEST['search_string'])) {
         $this->return['inputs']['shipon_history_search'] = $_REQUEST['search_string'];
     }
     if (isset($_REQUEST['sort_by'])) {
         $this->return['inputs']['shipon_history_sort_by'] = $_REQUEST['sort_by'];
     } else {
         $this->return['inputs']['shipon_history_sort_by'] = '0';
     }
     if (isset($_REQUEST['sort_order'])) {
         $this->return['inputs']['shipon_history_sort_order'] = $_REQUEST['sort_order'];
     }
     $pagination = $this->get_paged_footer("#history", $xml->entries_per_page, $pageCount, $xml->page_numbers);
     $this->smarty->assign('shipment', $shipment);
     $this->smarty->assign('request', $req);
     $this->smarty->assign('pagination', $pagination);
     $this->html['shipon_content'] = $this->smarty->fetch('history/history.tpl');
 }
开发者ID:kamalspalace,项目名称:_CORE,代码行数:59,代码来源:history.php

示例6: check_mail

/**
 * sees if the user has any new mail
 */
function check_mail()
{
    $user_id = $_SESSION['id'];
    connect_sql();
    $query = @query("SELECT * FROM `mail` WHERE `read`='0' AND `deleted`='0' AND `to`='{$user_id}'") or die("Error checking the database.");
    $number = num_rows($query);
    disconnect_sql();
    return $number;
}
开发者ID:kfr2,项目名称:phpmygrades,代码行数:12,代码来源:maillib.php

示例7: format_address_array

function format_address_array(&$return_array, $query_result, $attribute)
{
    if (num_rows($query_result)) {
        $address = fetch($query_result);
        $keys = array_keys($address);
        for ($i = 0; $i < count($keys); $i++) {
            $new_key = $attribute . $keys[$i];
            $return_array[$new_key] = $address[$keys[$i]];
        }
    }
}
开发者ID:kamalspalace,项目名称:_CORE,代码行数:11,代码来源:functions.php

示例8: Check_Password_Reset

function Check_Password_Reset($id, $code)
{
    $date = date("Y-m-d");
    $daterange = "'" . $date . " 00:00:00' AND '" . $date . " 23:59:59'";
    $query = "SELECT * FROM `users` WHERE `id`='" . $id . "' AND `password_reset_code`='" . $code . "' AND `password_reset_date` BETWEEN " . $daterange . ";";
    $users = query($query);
    if ($users && num_rows($users) === 1) {
        return true;
    } else {
        return false;
    }
}
开发者ID:Alamantus,项目名称:Lexiconga,代码行数:12,代码来源:passwordreset.php

示例9: send_mail_by_userid

function send_mail_by_userid($userid, $subject, $text)
{
    $userid = (int) $userid;
    $sql = "SELECT u.email\n\t\tFROM " . PREF . "users AS u\n\t\tWHERE u.id={$userid}\n\t\tLIMIT 1";
    $result = query($sql);
    $rows = num_rows($result);
    if (!$rows) {
        return;
    }
    $emails = fetch_row($result);
    return send_mail_to_first($emails, $subject, $text);
}
开发者ID:Bodigrim,项目名称:durmstrang,代码行数:12,代码来源:mail.php

示例10: libera_acesso

function libera_acesso($item, $id_conn)
{
    if ($_SESSION['admin'] == '0') {
        $sql = "SELECT tb_usuarioquaisacessos.usuarioquaisacessos_id FROM tb_acesso ";
        $sql .= "INNER JOIN tb_usuarioquaisacessos ON (tb_usuarioquaisacessos.acesso_id = tb_acesso.acesso_id) ";
        $sql .= "WHERE tb_acesso.acesso_nome='%s' ";
        $sql .= "AND tb_usuarioquaisacessos.usuario_id = '%s' LIMIT 1";
        $sql = sprintf($sql, mysql_real_escape_string($item), mysql_real_escape_string($_SESSION['usuario_id']));
        $acessou = execute_query($sql, $id_conn);
        if (!$acessou) {
            $messagem = 'Query Inválida: ' . mysql_error() . "\n";
            $messagem .= 'Pesquisa Inteira: ' . $sql;
            die($messagem);
        }
        if (num_rows($acessou) == 0) {
            header("Location: acesso_proibido.php");
            exit(0);
        }
    }
}
开发者ID:kureshio,项目名称:colecao,代码行数:20,代码来源:funcao.php

示例11: loginbypost

function loginbypost()
{
    global $LU, $attempt;
    $post_get = new GetVarClass();
    $email = $post_get->getemail("email");
    $pw = $post_get->getvar("pw");
    if (!$email || !$pw) {
        return 0;
    }
    $subquery = "u.email='{$email}'";
    $attempt = 1;
    $sql = "SELECT u.id,u.pw\n\t\tFROM " . PREF . "users AS u\n\t\tWHERE {$subquery} AND (u.pwhash=MD5('{$pw}') OR '{$LU["moderid"]}'<>0) AND u.active\n\t\tLIMIT 1";
    $result = query($sql);
    $rows = num_rows($result);
    if ($rows) {
        list($LU["id"], $knownpw) = fetch_row($result);
        if (!ALLOWMULTISESSIONS) {
            dropallsessions($LU["id"]);
        }
    }
    return $rows;
}
开发者ID:Bodigrim,项目名称:durmstrang,代码行数:22,代码来源:login.php

示例12: lookup

	public function lookup($message) {
		$name = $this->extractName($message);

		if(empty($name))
			return false;

		if(($data = $this->cacheFetch($name)) !== false)
			return $data;

		$result = perform_query(
			"SELECT * FROM lzecs" .
			" WHERE name = '{$name}' LIMIT 1",
			$this->dbLink, $_SERVER['PHP_SELF']
		);

		if(! num_rows($result) > 0)
			return false;

		$data = array();
		$row  = fetch_array($result, "ASSOC");

		array_push($data, $name);
		array_push($data, $row['preg_msg']);
		array_push($data, $row['explanation']);
		array_push($data, $row['action']);
		array_push($data, $row['si']);
		array_push($data, $row['psr']);
		array_push($data, $row['suppress']);
		array_push($data, $row['trig_amt']);
		array_push($data, $row['trig_win']);
		array_push($data, $row['vendor']);
		array_push($data, $row['type']);
		array_push($data, $row['class']);
		array_push($data, $row['lastupdate']);
		$this->cacheStore($name, $data);

		return $data;
	}
开发者ID:Russell-IO,项目名称:php-syslog-ng,代码行数:38,代码来源:LZECS.class.php

示例13: lookup

 public function lookup($message)
 {
     $name = $this->extractName($message);
     if (empty($name)) {
         return false;
     }
     if (($data = $this->cacheFetch($name)) !== false) {
         return $data;
     }
     $result = perform_query("SELECT message, explanation, action, datetime FROM " . CISCO_ERROR_TABLE . " WHERE name = '{$name}' LIMIT 1", $this->dbLink);
     if (!num_rows($result) > 0) {
         return false;
     }
     $data = array();
     $row = fetch_array($result, "ASSOC");
     array_push($data, $name);
     array_push($data, $row['message']);
     array_push($data, $row['explanation']);
     array_push($data, $row['action']);
     array_push($data, $row['datetime']);
     $this->cacheStore($name, $data);
     return $data;
 }
开发者ID:jeroenrnl,项目名称:php-syslog-ng,代码行数:23,代码来源:CEMDB.class.php

示例14: downloads

function downloads($cat = 0)
{
    global $downloadsmessage, $prefix;
    if ($cat) {
        $query = "SELECT * FROM " . $prefix . "downloadscat WHERE id=" . $cat . " ORDER BY nome";
    } else {
        if (!($crow = fetch_array(dbquery("SELECT * FROM " . $prefix . "downloadscat WHERE nome=\"Uploads\"")))) {
            die($downloadsmessage[2]);
        }
        $query = "SELECT * FROM " . $prefix . "downloadscat WHERE id<>" . $crow['id'] . " ORDER BY nome";
    }
    if (!($cresult = dbquery($query))) {
        die($downloadsmessage[2]);
    }
    $out .= "\n<div id=\"LNE_show\">\n";
    while ($crow = fetch_array($cresult)) {
        $out .= "<h3>" . decode($crow['descr']) . "</h3>";
        $query = "SELECT * FROM " . $prefix . "downloads WHERE ex=" . $crow['id'] . " ORDER BY reg DESC";
        if (!($result = dbquery($query))) {
            die($downloadsmessage[3]);
        }
        if (num_rows($result)) {
            $GETarray = $_GET;
            $out .= "<ul>";
            while ($row = fetch_array($result)) {
                $GETarray['dlid'] = $row[0];
                $out .= "<li><a href=\"addons/downloads/send.php?" . http_build_query($GETarray, '', '&amp;') . "\" rel=\"nofollow\">" . decode($row[1]) . "</a></li>\n";
            }
            $out .= "</ul>";
        } else {
            $out .= "<h3>{$downloadsmessage['100']}</h3>";
        }
    }
    $out .= "</div>\n";
    return $out;
}
开发者ID:squidjam,项目名称:LightNEasy,代码行数:36,代码来源:main.php

示例15: values

    $msgsave = "Suppression effectuée";
}
if ($_POST["mode"] == "ajout") {
    //vérification des droit du compte
    $sql = "insert into " . __racinebd__ . "categorie_compte (libelle,compte_id) values('" . addquote($_POST["libelle"]) . "'," . $_SESSION["compte_id"] . ")";
    //print $sql."<br>";
    $link = query($sql);
    $msgsave = "ajout";
}
if ($_POST["id"] != "" && $_POST["mode"] == "modif") {
    //vérification des droit du compte
    $sql = "update " . __racinebd__ . "categorie_compte set libelle ='" . addquote($_POST["libelle"]) . "'  where categorie_compte_id=" . $_POST["id"] . " and compte_id=" . $_SESSION["compte_id"];
    //print $sql."<br>";
    $link = query($sql);
    $msgsave = "modif";
}
$sql = "select * from " . __racinebd__ . "categorie_compte where compte_id=" . $_SESSION["compte_id"] . " and supprimer=0 order by libelle";
//$sql="select tlc.*,count(lc.device_id) as nb from ".__racinebd__."categorie_compte tlc left join ".__racinebd__."device lc on tlc.categorie_compte_id=lc.categorie_id and lc.supprimer=0 where tlc.supprimer=0 and lc.compte_id=".$_SESSION["compte_id"]." group by tlc.categorie_compte_id order by libelle";
$link = query($sql);
while ($tbl = fetch($link)) {
    $sql = "select * from " . __racinebd__ . "categorie_compte_device ccd inner join " . __racinebd__ . "device d on d.device_id=ccd.device_id and supprimer=0 and categorie_compte_id=" . $tbl["categorie_compte_id"];
    $link2 = query($sql);
    $tbl["nb"] = num_rows($link2);
    $tbl_list_categorie[] = $tbl;
    //  $key_list_agence[$tbl["categorie_compte_id"]]=$tbl["libelle"];
}
if ($_POST["id"] != "" && $_POST["mode"] == "") {
    $sql = "select * from " . __racinebd__ . "categorie_compte where compte_id=" . $_SESSION["compte_id"] . " and categorie_compte_id=" . $_POST["id"] . " order by libelle";
    $link = query($sql);
    $tbl_modif_categorie = fetch($link);
}
开发者ID:jcmwc,项目名称:fleet,代码行数:31,代码来源:parametre-catveh.php


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