本文整理汇总了PHP中mysql_numrows函数的典型用法代码示例。如果您正苦于以下问题:PHP mysql_numrows函数的具体用法?PHP mysql_numrows怎么用?PHP mysql_numrows使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mysql_numrows函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Ver_Formulario_Registro_Comentario
function Ver_Formulario_Registro_Comentario($id_comentario)
{
global $database;
if (!$id_comentario) {
return;
}
$q = "SELECT id_comentario, codigo, comentario, timestamp, tipo FROM " . TBL_COMMENTS . " WHERE id_comentario={$id_comentario}" . ";";
$result = $database->query($q);
$num_rows = @mysql_numrows($result);
if (!$result || $num_rows < 0) {
echo Mensaje("Error mostrando la información", _M_ERROR);
return;
}
if ($num_rows == 0) {
echo Mensaje("¡No hay comentarios ingresados!", _M_NOTA);
return;
}
//$id_comentario
$codigo = mysql_result($result, 0, "codigo");
$comentario = mysql_result($result, 0, "comentario");
$timestamp = mysql_result($result, 0, "timestamp");
$tipo = mysql_result($result, 0, "tipo") == 0 ? '' : 'checked="checked"';
// Creamos los campos del formulario.
$Campo_Comentario_id_comentario_hidden = '<input type="hidden" name="id_comentario" value="' . $id_comentario . '">';
$Campo_Comentario_id_comentario = '<tr><td width="25%">Identificador</td><td><b>' . $id_comentario . '</b></td></tr>';
$Campo_Comentario_codigo = '<tr><td>Cliente:</td><td>' . $database->Combobox_usuarios("codigo", $codigo) . '</td></tr>';
$Campo_Comentario_comentario = '<tr><td>Comentario:</td><td><input type="text" name="comentario" maxlength="100" value="' . $comentario . '"></td></tr>';
$Campo_Comentario_timestamp = '<tr><td>Hora y Fecha</td><td><b>' . date('h:i:s @ d/m/Y', $timestamp) . '</b></td></tr>';
$Campo_Comentario_tipo = '<tr><td>¿Comentario público?:</td><td><input type="checkbox" name="tipo" ' . $tipo . ' value="publico" /></tr></td>';
// Botones de acción
$BotonCancelar = '<input type="button" OnClick="window.location=\'./?' . _ACC_ . '=gestionar+comentarios\'" value="Cancelar">';
// Mostramos el formulario.
echo '<form action="./?' . _ACC_ . '=gestionar+comentarios" method="POST">' . '<table>' . $Campo_Comentario_id_comentario_hidden . $Campo_Comentario_id_comentario . $Campo_Comentario_codigo . $Campo_Comentario_comentario . $Campo_Comentario_timestamp . $Campo_Comentario_tipo . '</table><br />' . '<input type="submit" value="Editar">' . $BotonCancelar . '<input type="hidden" name="registrar_comentario" value="1">' . '</form>';
}
示例2: page
function page($theme)
{
include "includes/smileyparse.php";
if (isset($_GET['page'])) {
$page = $_GET['page'];
$query = "SELECT * FROM pages WHERE id_string = '{$page}'";
$result = mysql_query($query);
$num = mysql_numrows($result);
if ($num == 0) {
echo '<div class="entry">No such page!</div>';
} else {
$id = mysql_result($result, 0, "id");
$title = mysql_result($result, 0, "title");
$page = mysql_result($result, 0, "page");
$page = parseSmiley($page);
$page = stripslashes($page);
echo '<div class="entry"><h3>';
echo $title;
echo '</h3><p>';
echo $page;
echo '</div>';
}
} else {
echo '<div class="entry">You must specify a page!</div>';
}
}
示例3: displayBannedUsers
/**
* displayBannedUsers - Displays the banned users
* database table in a nicely formatted html table.
*/
function displayBannedUsers(){
global $database;
$q = "SELECT username,timestamp "
."FROM ".TBL_BANNED_USERS." ORDER BY username";
$result = $database->query($q);
/* Error occurred, return given name by default */
$num_rows = mysql_numrows($result);
if(!$result || ($num_rows < 0)){
echo "Error displaying info";
return;
}
if($num_rows == 0){
echo "Database table empty";
return;
}
/* Display table contents */
echo "<table align=\"left\" border=\"1\" cellspacing=\"0\" cellpadding=\"3\">\n";
echo "<tr><td><b>Username</b></td><td><b>Time Banned</b></td></tr>\n";
for($i=0; $i<$num_rows; $i++){
$uname = mysql_result($result,$i,"username");
$time = mysql_result($result,$i,"timestamp");
echo "<tr><td>$uname</td><td>$time</td></tr>\n";
}
echo "</table><br>\n";
}
示例4: dok_create_album
function dok_create_album()
{
global $VARS, $USER;
if (!isset($VARS['name'])) {
dok_msg(MSG_ERR_NO_ALBUM_NAME, 'dok_create_album', 'e');
return false;
}
if (!strlen(trim($VARS['name']))) {
dok_msg(MSG_ERR_NO_ALBUM_NAME, 'dok_create_album', 'e');
return false;
}
$album_name = ucwords(substr($VARS['name'], 0, 255));
$res = mysql_query('select id from ' . dok_tn('album') . ' where name = \'' . addslashes($album_name) . '\'');
if (mysql_numrows($res)) {
dok_msg(sprintf(MSG_ERR_DUP_ALBUM_NAME, $album_name), 'dok_create_album', 'e');
return false;
}
if (DOK_ENABLE_USER) {
$creation_uid = $USER->id;
} else {
$creation_uid = 0;
}
//add artist
$res = dok_uquery('insert into ' . dok_tn('album') . ' (name,creation,creation_uid) values (\'' . addslashes($album_name) . '\',' . time() . ',' . $creation_uid . ')');
if (!$res) {
dok_msg(mysql_error(), 'dok_create_album', 'e');
return false;
}
$VARS['id'] = mysql_insert_id();
$_SESSION['song_select_album'] = $VARS['id'];
return 'view_album';
}
示例5: recent
function recent()
{
echo '<h4>Recent posts</h4>';
$query = "SELECT * FROM news ORDER BY id DESC LIMIT 5";
$result = mysql_query($query);
$num = mysql_numrows($result);
if ($num == 0) {
echo 'No posts in database';
} else {
$i = 0;
while ($i < $num) {
$id = mysql_result($result, $i, "id");
$title = mysql_result($result, $i, "title");
?>
<div class="navtext">> <a href="index.php?module=news&article=<?php
echo $id;
?>
"><?php
echo $title;
?>
</a></div>
<?php
$i++;
}
}
}
示例6: getcomments
function getcomments($id)
{
$query = "SELECT * FROM comments WHERE article = {$id}";
$result = mysql_query($query);
$num = mysql_numrows($result);
echo "<a href=\"index.php?module=news&article={$id}\">{$num} comments</a>";
}
示例7: listQuizes
/**
* @name: listQuizes
* @type: Public
* @description: Списък със всички добавени тестове и възможност за решаване на
*/
public function listQuizes()
{
//Извикваме нужните ни класове
global $db, $filter;
//Нулираме си променливите
$allQuizes = array();
$page = 0;
$disciplineName = $filter->input($_GET['id']);
//Ако е избран предмет извличаме id-то му
if ($disciplineName != null) {
$allDisciplines = mysql_fetch_array($db->getDisciplineByName($disciplineName));
if (mysql_numrows($db->getDisciplineByName($disciplineName)) == 1) {
$discipline = $allDisciplines['id'];
} else {
$discipline = "False";
}
}
//Филтрираме променливата за страницата
if (isset($_GET['page'])) {
$page = $filter->input($_GET['page']);
}
//Вземане на тестовете, според поисканата страица
$allQuizes = $db->listQuizes($page, 1, $discipline);
//Заглавие на страницата
$title = "Тестове | " . SITE_NAME;
//Визуализираме списъка
require_once TEMPLATE . "listQuizes.tpl.php";
}
示例8: displayUsers
function displayUsers()
{
global $database;
$q = "SELECT username,userlevel,email,timestamp " . "FROM " . TBL_USERS . " ORDER BY userlevel DESC,username";
$result = $database->query($q);
$num_rows = mysql_numrows($result);
if (!$result || $num_rows < 0) {
echo "Error displaying info";
return;
}
if ($num_rows == 0) {
echo "Database table empty";
return;
}
echo "<table align=\"left\" border=\"1\" cellspacing=\"0\" cellpadding=\"3\">\n";
echo "<tr><td><b>Username</b></td><td><b>Level</b></td><td><b>Email</b></td><td><b>Last Active</b></td></tr>\n";
for ($i = 0; $i < $num_rows; $i++) {
$uname = mysql_result($result, $i, "username");
$ulevel = mysql_result($result, $i, "userlevel");
$email = mysql_result($result, $i, "email");
$time = mysql_result($result, $i, "timestamp");
echo "<tr><td>{$uname}</td><td>{$ulevel}</td><td>{$email}</td><td>{$time}</td></tr>\n";
}
echo "</table><br>\n";
}
示例9: dok_box_ranked
function dok_box_ranked($display_module, $theme_path)
{
if (DOK_USE_CACHE) {
$fname = dok_c_box_filename('ranked', 'ignored');
$cache = dok_c_get($fname);
if ($cache) {
return $cache;
}
}
$res = mysql_query('select name, id from ' . dok_tn('song') . ' order by hits desc limit 10');
echo mysql_error();
if (!mysql_numrows($res)) {
return;
}
$t = new template($theme_path);
$t->set_file('page', 'box_default.tpl');
$t->set_var('BOXTITLE', MSG_TITLE_BOX_RANKED_SONG);
$t->set_block('page', 'boxlink', 'boxlinktag');
$t->set_var('boxlinktag', '');
if (!mysql_numrows($res)) {
$t->set_var('BOXCONTENT', '');
}
while ($row = mysql_fetch_array($res)) {
$t->set_var('LINK', $_SERVER['PHP_SELF'] . '?display=view_song&id=' . $row['id']);
$t->set_var('LABEL', $row['name']);
$t->parse('BOXCONTENT', 'boxlink', 'true');
}
$html = $t->parse('out', 'page');
if (DOK_USE_CACHE) {
dok_c_write($fname, $html);
}
return $html;
}
示例10: saveData
function saveData()
{
if ($this->connection()) {
$quser = mysql_query("select * from `customer_table` where cus_user='" . $this->getUser() . "' OR cus_email='" . $this->getEmail() . "' ");
if (mysql_numrows($quser) == 0) {
$query = mysql_query("insert into customer_table values(NULL,'" . $this->getUser() . "','" . $this->getPass() . "','" . $this->getEmail() . "')");
if ($query) {
$result['status'] = "1";
} else {
$result['status'] = "0";
}
} else {
$row = mysql_fetch_array($quser);
if ($row['cus_user'] == $this->getUser() && $row['cus_email'] == $this->getEmail()) {
$result['status'] = "4";
} elseif ($row['cus_user'] == $this->getUser()) {
$result['status'] = "2";
} elseif ($row['cus_email'] == $this->getEmail()) {
$result['status'] = "3";
} else {
$result['status'] = "0";
}
}
} else {
$result['status'] = "0";
}
echo json_encode($result);
}
示例11: lista
function lista($user)
{
global $dateformat;
$user = protect($user);
requirelogin();
$title = "Mensagens de {$user}";
include "libs/accounts.php";
// listar todas as mensagens de $user onde hidden = 'n' (para outro user ver)
$output = menu($user) . url("message/send/{$user}", "[enviar mensagem]") . "<br>\n";
$usr = resolveuser($user);
$qry = mysql_query("SELECT `from`,`content`,`data` FROM messages WHERE `to`='{$usr}' AND `hidden`='n' ORDER BY id DESC LIMIT 30");
if (mysql_numrows($qry) == 0) {
$output .= 'Nenhuma mensagem!';
} else {
while ($row = mysql_fetch_array($qry)) {
$user = mysql_query("SELECT login,foto FROM accounts WHERE id='{$row['from']}'");
$user = mysql_fetch_array($user);
$output .= '<p class="row">' . t("De") . ': ' . url("user/profile/{$user['login']}", $user['login']) . '<br/>';
$output .= '<blockquote>
' . bbcode($row['content']) . '
</blockquote>
<hr size="1"><i>' . date($dateformat, $row['data']) . '</i>
</p>';
}
}
section($output, $title);
}
示例12: index
function index()
{
global $timeformat, $home;
if (is_logged()) {
$output = '<p><form method="post" action="' . $home . 'shoutbox/escrevepost">
<textarea rows="8" cols="25" name="message"></textarea><br/>
<input type="submit" value="' . t("Enviar") . '">
</form></p><hr size="1">';
}
$qry = mysql_query("SELECT s.id AS d, s.text AS t, s.time AS i, a.login AS l FROM shoutbox s LEFT JOIN accounts a ON s.owner=a.id ORDER BY s.id DESC LIMIT 10");
if (mysql_numrows($qry) != 0) {
$response = true;
while ($row = mysql_fetch_array($qry)) {
$output .= '<p><h3>' . $row['t'] . '</h3><br/><h6>' . t("postado por") . ' ' . url("user/profile/{$row['l']}", $row['l']) . ' ' . t("em") . ' ' . date($timeformat, $row['i']);
if (is_admin()) {
$output .= '<br>' . url("shoutbox/del/{$row['d']}", t("[excluir]"));
}
$output .= '</p><hr size="1">';
}
} else {
$output .= infobox(t("Não há mensagens na shoutbox."), false);
}
if ($response) {
section(substr($output, 0, -13), t("Shoutbox"));
} else {
section($output, t("Shoutbox"));
}
}
示例13: links
function links()
{
echo '<h4>Links</h4>';
$query = "SELECT * FROM links";
$result = mysql_query($query);
$num = mysql_numrows($result);
$i = 0;
while ($i < $num) {
$link_name = mysql_result($result, $i, "link_name");
$link_description = mysql_result($result, $i, "link_description");
$link_target = mysql_result($result, $i, "link_location");
?>
<div class="navtext">> <a href="<?php
echo $link_target;
?>
" title="<?php
echo $link_description;
?>
"><?php
echo $link_name;
?>
</a></div>
<?php
$i++;
}
}
示例14: __construct
public function __construct($host, $user, $pass)
{
$body = "_[l[Shacker Birthdays:]l]_ \n";
//TODO: refactor out passwords/mysql connection details?
$connection = mysql_connect($host, $user, $pass);
$numRows = 0;
$averageAge = 0;
if ($connection !== False) {
// TODO: refactor this out too
mysql_select_db("shackdb");
// fetch birthdays first on same connection
$query = "select avg(year) as avg_year from (SELECT substring(dob,1,4) as year from birthdays having year > 1901 and year < 2005) as tb1;";
$result = mysql_query($query);
$averageAge = mysql_fetch_array($result, MYSQL_ASSOC);
$averageAge = date("Y") - floatval($averageAge["avg_year"]);
$query = "SELECT * FROM birthdays where dob like '%" . date('m-d') . "'";
$result = mysql_query($query);
$numRows = mysql_numrows($result);
}
if ($numRows > 0) {
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
$body .= "y{" . $row["username"] . "}y" . self::agestring($row["dob"], $row["username"]) . "\n";
}
$body .= "\n";
$body .= "And as always, Happy Birthday, Shackers from the y{the man with the briefcase}y!!\n";
} else {
$body .= "\n";
$body .= "No birthdays today!\n";
}
$body .= "\n";
$body .= "s[The average shackage is now " . number_format($averageAge, 2, '.', '') . "!]s\n";
$body .= "s[Want to add your birthday? http://shack.asktherelic.com/birthday.php]s";
parent::__construct($body);
}
示例15: availableElems
function availableElems()
{
$db = new db();
$log = ADLog::getInstance();
/*
* Extract all Policy Elements for select list below
*/
$q = "SELECT id, elementName FROM compliancePolElem WHERE status = 1 ORDER BY elementName ASC";
$result = $db->q($q);
$num_rows = mysql_numrows($result);
if (!$result || $num_rows < 0) {
$log->Warn("Failure: Problem Displaying compliancePolElem options (File: " . $_SERVER['PHP_SELF'] . ")");
echo "Error displaying info for availableElems() function";
return;
}
if ($num_rows == 0) {
$log->Warn("Failure: Problem Displaying availableElems() - no options returned (File: " . $_SERVER['PHP_SELF'] . ")");
echo "Database table empty";
return;
}
for ($i = 0; $i < $num_rows; $i++) {
$id = mysql_result($result, $i, "id");
$elementName = mysql_result($result, $i, "elementName");
echo "<option value=" . $id . ">" . $elementName . "</option>";
}
}