本文整理汇总了PHP中mysql_fetch_array函数的典型用法代码示例。如果您正苦于以下问题:PHP mysql_fetch_array函数的具体用法?PHP mysql_fetch_array怎么用?PHP mysql_fetch_array使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mysql_fetch_array函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fromOpenID2CardID
function fromOpenID2CardID($openid)
{
$mysql_host = SAE_MYSQL_HOST_M;
$mysql_host_s = SAE_MYSQL_HOST_S;
$mysql_port = SAE_MYSQL_PORT;
$mysql_user = SAE_MYSQL_USER;
$mysql_password = SAE_MYSQL_PASS;
$mysql_database = SAE_MYSQL_DB;
$mysql_table = "member";
$mysql_state = "SELECT * FROM " . $mysql_table . " WHERE `openid` = '" . $openid . "'";
$con = mysql_connect($mysql_host . ':' . $mysql_port, $mysql_user, $mysql_password, true);
if (!$con) {
die('Could not connect: ' . mysql_error());
}
mysql_query("SET NAMES 'UTF8'");
mysql_select_db($mysql_database, $con);
$result = mysql_query($mysql_state);
$cardID = "";
while ($row = mysql_fetch_array($result)) {
$cardID = $row['cardid'];
break;
}
mysql_close($con);
return $cardID;
}
示例2: checkIndividually
function checkIndividually()
{
#----------------------------------------------------------------------
global $competitionCondition, $chosenWhich;
echo "<hr /><p>Checking <b>" . $chosenWhich . " individual results</b>... (wait for the result message box at the end)</p>\n";
#--- Get all results (id, values, format, round).
$dbResult = mysql_query("\n SELECT\n result.id, formatId, roundId, personId, competitionId, eventId, result.countryId,\n value1, value2, value3, value4, value5, best, average\n FROM Results result, Competitions competition\n WHERE competition.id = competitionId\n {$competitionCondition}\n ORDER BY formatId, competitionId, eventId, roundId, result.id\n ") or die("<p>Unable to perform database query.<br/>\n(" . mysql_error() . ")</p>\n");
#--- Build id sets
$countryIdSet = array_flip(getAllIDs(dbQuery("SELECT id FROM Countries")));
$competitionIdSet = array_flip(getAllIDs(dbQuery("SELECT id FROM Competitions")));
$eventIdSet = array_flip(getAllIDs(dbQuery("SELECT id FROM Events")));
$formatIdSet = array_flip(getAllIDs(dbQuery("SELECT id FROM Formats")));
$roundIdSet = array_flip(getAllIDs(dbQuery("SELECT id FROM Rounds")));
#--- Process the results.
$badIds = array();
echo "<pre>\n";
while ($result = mysql_fetch_array($dbResult)) {
if ($error = checkResult($result, $countryIdSet, $competitionIdSet, $eventIdSet, $formatIdSet, $roundIdSet)) {
extract($result);
echo "Error: {$error}\nid:{$id} format:{$formatId} round:{$roundId}";
echo " ({$value1},{$value2},{$value3},{$value4},{$value5}) best+average({$best},{$average})\n";
echo "{$personId} {$countryId} {$competitionId} {$eventId}\n\n";
$badIds[] = $id;
}
}
echo "</pre>";
#--- Free the results.
mysql_free_result($dbResult);
#--- Tell the result.
noticeBox2(!count($badIds), "All checked results pass our checking procedure successfully.<br />" . wcaDate(), count($badIds) . " errors found. Get them with this:<br /><br />SELECT * FROM Results WHERE id in (" . implode(', ', $badIds) . ")");
}
示例3: retorna_imagem_perfil
function retorna_imagem_perfil($idusuario)
{
// globals ----------------------------------------------
global $tabela_banco;
// tabela de banco de dados
global $imagem_servidor;
// imagens de servidor
// --------------------------------------------------------
// query ------------------------------------------------
$query = "select *from {$tabela_banco['2']} where idusuario='{$idusuario}';";
// query
// --------------------------------------------------------
// comando -------------------------------------------
$comando = comando_executa($query);
// comando
// --------------------------------------------------------
// dados -----------------------------------------------
$dados = mysql_fetch_array($comando, MYSQL_ASSOC);
// dados
// --------------------------------------------------------
// imagem de perfil ----------------------------------
$imagem_perfil = $dados['imagem_perfil'];
// imagem de perfil
// --------------------------------------------------------
// imagem de servidor padrao ------------------------------
if ($imagem_perfil == null) {
$imagem_perfil = $imagem_servidor['usuario'];
// imagem de servidor padrao
}
// -----------------------------------------------------------------
// retorno -------------------------------------------------------
return $imagem_perfil;
// retorno
// -----------------------------------------------------------------
}
示例4: candidatesArePeopleToo
function candidatesArePeopleToo()
{
$s = mysql_query("SELECT * FROM candidates");
while ($r = mysql_fetch_array($s)) {
$name = $r['name_cleaned'];
$sid = $r['id'];
if (strpos($r['url'], "http://") === 0) {
$url = $r['url'];
} else {
$url = 'http://www.alegeri-2008.ro' . $r['url'];
}
$idString = '<a href=' . $url . '>alegeri2008</a>';
$persons = getPersonsByName($name, $idString);
// If I reached this point, I know for sure I either have one
// or zero matches, there are no ambiguities.
if (count($persons) == 0) {
$person = addPersonToDatabase($name, $r['name_cleaned']);
} else {
$person = $persons[0];
info("Found {" . $name . "}");
}
// First and foremost, attempt to add this to the person's history.
addPersonHistory($person->id, "alegeri/2008", $url);
// Locate these people and update them in several tables now.
// We're mainly interested in updating the ID to the new ID that
// will be in the People database, from the previous ID that was
// the senator's ID in the senators table.
mysql_query("UPDATE candidates " . "SET idperson={$person->id} " . "WHERE id=" . $r['id']);
}
}
示例5: popup
function popup()
{
$page = CurrentPageName();
$tpl = new templates();
$users = new usersMenus();
$q = new mysql();
$sql = "SELECT * FROM officials_domains ORDER BY domain";
writelogs("{$sql}", __FUNCTION__, __FILE__, __LINE__);
$results = $q->QUERY_SQL($sql, "artica_backup");
if (!$q->ok) {
echo "<H2>{$q->mysql_error}</H2>";
}
while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) {
$domains[$ligne["domain"]] = $ligne["domain"];
}
$OverWriteRestrictedDomains = 0;
if ($users->OverWriteRestrictedDomains) {
$OverWriteRestrictedDomains = 1;
}
if ($OverWriteRestrictedDomains == 1) {
$over = "\n\t\t<hr>\n\t\t<div class=explain>{OverWriteRestrictedDomains_allow_text}</div>\n\t\t<table style='width:99%' class=form>\n\t<tr>\n\t\t<td class=legend>{domain}:</td>\n\t\t<td width=100%>" . Field_text("overwrite-domain", null, "font-size:16px;padding:3px;width:320px") . "</td>\n\t</tr>\n\t<tr>\n\t\t<td colspan=2 align='right'><hr>" . button("{add}", "AddSubdomainOUOver()") . "</td>\n\t</tr>\n\t</table>\n\t\t";
}
$_GET["ou"] = urlencode($_GET["ou"]);
$domains[null] = "{select}";
$html = "\n\t<div id='add_subdomain_explain'></div>\n\t<div class=explain >{add_subdomain_explain}</div>\n\t\n\t<table style='width:99%' class=form>\n\t<tr>\n\t\t<td class=legend>{subdomain}:</td>\n\t\t<td width=50%>" . Field_text("subdomain", null, "font-size:16px;padding:3px;width:220px") . "</td>\n\t\t<td style='font-size:16px;padding:3px' width=1%><strong>.</strong></td>\n\t\t<td width=50%>" . Field_array_Hash($domains, "maindomain", null, "style:font-size:16px;padding:3px;") . "</td>\n\t</tr>\n\t<tr>\n\t\t<td colspan=4 align='right'><hr>" . button("{add}", "AddSubdomainOU()") . "</td>\n\t</tr>\n\t</table>\n\t{$over}\n\t<script>\n\tvar x_AddSubdomainOU= function (obj) {\n\t\tvar results=obj.responseText;\n\t\tdocument.getElementById('subdomain').innerHTML='';\n\t\tif(results.length>3){alert(results);return;}\n\t\tYahooWin4Hide();\n\t\tLoadAjax('LocalDomainsList','domains.edit.domains.php?LocalDomainList=yes&ou={$_GET["ou"]}');\n\t}\t\t\n\t\t\n\t\tfunction AddSubdomainOU(){\n\t\t\tvar maindomain=document.getElementById('maindomain').value;\n\t\t\tvar subdomain=document.getElementById('subdomain').value;\n\t\t\tif(maindomain.length<3){return;}\n\t\t\tif(subdomain.length<3){return;}\n\t\t\tvar domain=subdomain+'.'+maindomain;\n\t\t\tvar XHR = new XHRConnection();\n\t\t\tXHR.appendData('AddNewInternetDomain','{$_GET["ou"]}');\n\t\t\tXHR.appendData('AddNewInternetDomainDomainName',domain);\t\n\t\t\tAnimateDiv('add_subdomain_explain');\n\t\t\tXHR.sendAndLoad('domains.edit.domains.php', 'GET',x_AddSubdomainOU);\n\t\t\t\n\t\t}\n\t\t\n\t\tfunction AddSubdomainOUOver(){\n\t\t\tvar maindomain=document.getElementById('overwrite-domain').value;\n\t\t\tif(maindomain.length<3){return;}\n\t\t\tvar XHR = new XHRConnection();\n\t\t\tXHR.appendData('AddNewInternetDomain','{$_GET["ou"]}');\n\t\t\tXHR.appendData('AddNewInternetDomainDomainName',maindomain);\t\n\t\t\tAnimateDiv('add_subdomain_explain');\n\t\t\tXHR.sendAndLoad('domains.edit.domains.php', 'GET',x_AddSubdomainOU);\t\t\t\n\t\t}\n\n\t</script>\n\t";
echo $tpl->_ENGINE_parse_body($html);
}
示例6: saveRatinglist
public function saveRatinglist()
{
foreach ($this->ratings as $player) {
//Controleren of speler al bestaat + ophalen id
$sql = "SELECT * FROM svn_leden WHERE knsb = " . $player["knsb"];
$query = mysql_query($sql);
if (mysql_num_rows($query) == 1) {
$data = mysql_fetch_assoc($query);
$player["id"] = $data["id"];
} elseif (mysql_num_rows($query) == 0) {
//Toevoegen van de speler
print_r($player);
}
//Controleren of de rating al bestaat
$sql = "SELECT * FROM svn_rating WHERE id = " . $player["id"] . " AND datum = '" . $this->ratingList . "'";
$query = mysql_query($sql);
if (mysql_num_rows($query) == 0) {
//Toevoegen rating
$sql = "INSERT INTO svn_rating VALUES ('',\"" . $this->ratingList . "\"," . $player["id"] . ",1," . $player["rating"] . ")";
mysql_query($sql);
}
}
$sql = "SELECT * FROM svn_leden WHERE knsb = " . $speler_geg["id"];
$result = mysql_query($sql);
$speler_dat = mysql_fetch_array($result);
if ($speler_geg["rating"] != "") {
$sql = "INSERT INTO svn_rating VALUES ('',\"" . $datum . "\"," . $speler_dat[0] . ",1," . $speler_geg["rating"] . ")";
//echo $sql;
mysql_query($sql);
}
}
示例7: getById
public static function getById($from, $id)
{
$sql = "SELECT * FROM `" . $from . "` WHERE `id` = '" . $id . "'";
$result = mysql_query($sql);
$info = mysql_fetch_array($result);
return $info;
}
示例8: select
/**
* 功能:数据库查询函数
* 参数:$sql SQL语句
* 返回:二唯数组或false
*/
public function select($sql = "")
{
if (empty($sql)) {
return false;
}
//如果SQL语句为空则返回FALSE
if (empty($this->CONN)) {
return false;
}
//如果连接为空则返回FALSE
try {
//捕获数据库选择错误并显示错误文件
$results = mysql_query($sql, $this->CONN);
} catch (Exception $e) {
$msg = $e;
echo $msg;
include ERRFILE;
}
if (!$results or empty($results)) {
//如果查询结果为空则释放结果并返回FALSE
@mysql_free_result($results);
return false;
}
$count = 0;
$data = array();
while ($row = @mysql_fetch_array($results)) {
//把查询结果重组成一个二维数组
$data[$count] = $row;
$count++;
}
@mysql_free_result($results);
return $data;
}
示例9: getOneZLSelectResult
function getOneZLSelectResult($xmid, $pids = 0)
{
$result = mysql_query("select ids,xm_fl from czj_xm where ids='{$xmid}'");
$array = mysql_fetch_array($result);
$xmfl = $array['xm_fl'];
return mysql_query("select * from czj_xm_zl_select where xm_fl='{$xmfl}' and pids='{$pids}'");
}
示例10: select
function select()
{
global $table;
$result = mysql_query('SELECT * from ' . $this->{$table} . ' limit 1;');
$row = mysql_fetch_array($result);
print_r($row);
}
示例11: all
public function all($id)
{
$arr = array();
if ($id == '') {
$sql = "SELECT `venda`.`id`, `venda`.`nome`, `aula`.`endereco_video`, `aula`.`descricao`, `aula`.`curso_idcurso`, `aula`.`cliente_idcliente`, `curso`.`nome` AS `disciplina` FROM `aula` \n\t\tINNER JOIN `curso` ON `curso_idcurso`=`idcurso`;";
$vai = new MySQLDB();
$result = $vai->executeQuery($sql);
} else {
$sql = "SELECT `aula`.`idaula`, `aula`.`nome`, `aula`.`endereco_video`, `aula`.`descricao`, `aula`.`curso_idcurso`, `aula`.`cliente_idcliente`, `curso`.`nome` AS `disciplina` FROM `aula` \n\t\tINNER JOIN `curso` ON `curso_idcurso`=`idcurso` WHERE `aula`.`idaula` = {$id};";
$vai = new MySQLDB();
$result = $vai->executeQuery($sql);
}
while ($dados = mysql_fetch_array($result)) {
$cliente = new Aula();
$cliente->setidaula(array('idaula' => $dados['idaula']));
$cliente->setnome(array('nome' => $dados['nome']));
$cliente->setendereco_video(array('endereco_video' => $dados['endereco_video']));
$cliente->setdescricao(array('descricao' => $dados['descricao']));
$cliente->setcurso_idcurso(array('curso_idcurso' => $dados['curso_idcurso']));
$cliente->setcliente_idcliente(array('cliente_idcliente' => $dados['cliente_idcliente']));
$cliente->setdisciplina(array('disciplina' => $dados['disciplina']));
$arr[] = $cliente;
}
return $arr;
}
示例12: addm
function addm($char, $mes, $priv)
{
setlocale(LC_ALL, "ru_RU.CP1251");
if (!isset($char['sex']) || $char['sex'] == "male") {
$mes = preg_replace("/\\{([\\d\\w\\s]*?)\\|([\\d\\w\\s]*?)\\}/i", "\\1", $mes);
} else {
$mes = preg_replace("/\\{([\\d\\w\\s]*?)\\|([\\d\\w\\s]*?)\\}/i", "\\2", $mes);
}
$mes = '<span style="color:#FF2828;font-size:12px;">' . iconv("Windows-1251", "UTF-8//IGNORE", $mes) . '</style>';
$message = $mes;
$message = mysql_real_escape_string($message);
$sel = myquery("SELECT `count` FROM `game_bot_chat_resp` WHERE `id` = '" . $char['name'] . "';");
$n = mysql_fetch_array($sel);
if ($n['count'] <= 4) {
myquery("INSERT INTO `game_bot_chat_resp` (`id`,`count`) VALUES ('" . $char['name'] . "','1') ON DUPLICATE KEY UPDATE `count` = `count` + 1;");
$update_chat = myquery("insert into game_log (town,fromm,too,message,date,ptype) values (0,'-1','" . $char['user_id'] . "','" . $message . "','" . time() . "'," . $priv . ")");
} else {
$sel = myquery("SELECT `text` FROM `game_bot_chat_annoy` ORDER BY RAND() ASC LIMIT 1");
$mes = mysql_fetch_array($sel);
if (!isset($char['sex']) || $char['sex'] == "male") {
$mes = preg_replace("/\\{([\\d\\w\\s]*?)\\|([\\d\\w\\s]*?)\\}/i", "\\1", $mes);
} else {
$mes = preg_replace("/\\{([\\d\\w\\s]*?)\\|([\\d\\w\\s]*?)\\}/i", "\\2", $mes);
}
$message = mysql_real_escape_string('<span style="color:#FF2828;font-size:12px;">' . iconv("Windows-1251", "UTF-8//IGNORE", $mes['text']) . '</style>');
$update_chat = myquery("insert into game_log (town,fromm,too,message,date,ptype) values (0,'-1','" . $char['user_id'] . "','" . $message . "','" . time() . "'," . $priv . ")");
}
}
示例13: autenticar
public function autenticar($email, $passwd)
{
$search = "SELECT * FROM `usuarios` WHERE `usuarios`.`email` = '" . $email . "' AND `usuarios`.`senha` = '" . md5($passwd) . "';";
$res = mysql_query($search);
if (!$res) {
die('Consulta inválidaaaaaaa! ' . $search);
}
if ($aux = mysql_fetch_array($res)) {
if ($aux['validation_status'] == 1) {
return -1;
} else {
if ($aux['validation_status'] == 2) {
return -2;
} else {
$this->authenticatedCPF = $aux['cpf'];
while (strlen($this->authenticatedCPF) < 11) {
$this->authenticatedCPF = "0" . $this->authenticatedCPF;
}
return $aux['nivel_acesso'];
}
}
} else {
$this->authenticatedCPF = 0;
return 0;
}
}
示例14: getInsert
function getInsert($param, $name, $score)
{
$dbParams = get_object_vars($param);
$mysql_host = $dbParams['mysql_host'];
$mysql_user = $dbParams['mysql_user'];
$mysql_pass = $dbParams['mysql_pass'];
$dbName = $dbParams['dbName'];
$dbTable = $dbParams['dbTable'];
//connect
$link = mysql_connect($mysql_host, $mysql_user, $mysql_pass) or die('connection error: ' . mysql_error());
//select db
mysql_select_db($dbName) or die('DB error');
//check user highest score
$query_check_user = 'SELECT score FROM ' . $dbTable . ' WHERE name = ' . $name . ';';
$result_check_user = mysql_query($query_check_user) or die('Request down: ' . mysql_error());
$checkUser = mysql_fetch_array($result_check_user);
if ($checkUser['score'] < $score) {
//inserting new scores
$query_insert = 'INSERT INTO ' . $dbTable . '(name,score) VALUES (' . $name . ',' . $score . ') ON DUPLICATE KEY UPDATE score = VALUES(score);';
$result = mysql_query($query_insert) or die('Request insert down: ' . mysql_error());
}
return $result;
// clean
if (isset($result)) {
mysql_free_result($result);
}
// close
mysql_close($link);
}
示例15: user_email
function user_email($user_id)
{
global $DB, $LINK;
$RS = $DB->query("SELECT email FROM users WHERE id='" . $user_id . "'", $LINK);
$data = mysql_fetch_array($RS);
return $data["email"];
}