本文整理汇总了PHP中mysql_fetch_assoc函数的典型用法代码示例。如果您正苦于以下问题:PHP mysql_fetch_assoc函数的具体用法?PHP mysql_fetch_assoc怎么用?PHP mysql_fetch_assoc使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mysql_fetch_assoc函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createMainDataElement
function createMainDataElement($plan, $num, $dbConn)
{
if ($plan['dato_principal_' . $num] != NULL) {
$query_dato = sprintf("SELECT * FROM tipoDatosServicios WHERE id_tipoDato=%s", GetSQLValueString($plan['id_tipoDato_principal_' . $num], "int"));
$dato = mysql_query($query_dato, $dbConn) or die(mysql_error());
$row_dato = mysql_fetch_assoc($dato);
$display = true;
$label = "";
if ($row_dato['tipo'] == "boolean") {
if ($plan['dato_principal_' . $num] == "1") {
$label = $row_dato['label'];
} else {
$display = false;
}
} else {
if ($row_dato['display_label']) {
$label = $plan['dato_principal_' . $num] . " " . $row_dato['label'];
} else {
$label = $plan['dato_principal_' . $num];
}
}
if ($display) {
echo "<div class='dato'>";
echo "\t<li class='tipo_" . $plan['id_tipoDato_principal_' . $num] . "' value='" . $plan['dato_principal_' . $num] . "'>";
echo $label;
echo "\t</li>";
echo "</div>";
}
}
//if
}
示例2: larz_printrow
function larz_printrow($id)
{
$sql = "SELECT * FROM `procedure` WHERE `id` = {$id}";
$result = mysql_query($sql);
$row = mysql_fetch_assoc($result);
larz_printtypes($row);
}
示例3: getTangentText
function getTangentText($type, $keyword)
{
global $dbHost, $dbUser, $dbPassword, $dbName;
$link = @mysql_connect($dbHost, $dbUser, $dbPassword);
if (!$link) {
die("Cannot connect : " . mysql_error());
}
if (!@mysql_select_db($dbName, $link)) {
die("Cannot find database : " . mysql_error());
}
$result = mysql_query("SELECT sr_keywords, sr_text FROM soRandom WHERE sr_type = '" . $type . "' ORDER BY sr_ID ASC;", $link);
$tempCounter = 0;
while ($row = mysql_fetch_assoc($result)) {
$pKey = "/" . $keyword . "/";
$pos = preg_match($pKey, $row['sr_keywords']);
//echo $pos . " is pos<br>";
//echo $keyword;
//echo " is keyword and this is the search return: " . $row['keywords'];
if ($pos != 0) {
$text[$tempCounter] = stripslashes($row["sr_text"]);
$tempCounter++;
}
}
mysql_close($link);
//$text=htmlentities($text);
return $text;
}
示例4: service
function service($text)
{
$text = str_replace("\\\"","\"",$text);
$token = explode(",",$text);
$last_token = $token[sizeof($token)-1];
$last_token = trim($last_token);
$items = array();
$result = mysql_query("select firstName, lastName, email from employees where CONCAT(firstName,' ',lastName,' ', email) like '%$last_token%' order by email;");
while($row = mysql_fetch_assoc($result))
{
$text = '"'.$row["firstName"]." ".$row["lastName"].'"'."<".$row["email"].">";
$text_array = $token;
$text_array[sizeof($text_array)-1] = $text;
$text = join(",",$text_array);
$html = '"'.$row["firstName"]." ".$row["lastName"].'"'."[".$row["email"]."]";
$html = preg_replace("/".$last_token."/i","<b>$last_token</b>",$html);
$html = str_replace("[","<",$html);
$html = str_replace("]",">",$html);
$item = array("text"=>$text,"html"=>$html);
array_push($items,$item);
}
return $items;
}
示例5: getProveedor
public function getProveedor($index)
{
$sql = "SELECT pro_id FROM proveedores WHERE pro_rfc = '" . $this->partidas[$index]["row_rfc" . $index] . "'";
$res = $this->conexion->consultar($sql);
$row = mysql_fetch_assoc($res);
$this->partidas[$index]["row_proveedor" . $index] = $row["pro_id"];
}
示例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: getLoveHistory
public function getLoveHistory($page, $justUser = false)
{
$front = Frontend::getInstance();
$page--;
$l = $this->getLimit() * $page;
$where = '';
$sql = "SELECT count(*) " . "FROM " . LOVE_LOVE;
$res = mysql_query($sql);
$row = mysql_fetch_row($res);
$loves = $row[0];
$sql = "SELECT count(*) " . "FROM " . LOVE_LOVE . " " . "WHERE " . LOVE_LOVE . ".receiver = '" . $front->getUser()->getUsername() . "' " . "OR " . LOVE_LOVE . ".giver = '" . $front->getUser()->getUsername() . "' " . ($sql .= $justUser ? '' : "OR " . LOVE_LOVE . ".company_id = '" . $front->getUser()->getCompany_id() . "' ");
$sql .= $where . " " . "ORDER BY id DESC";
$res = mysql_query($sql);
$row = mysql_fetch_row($res);
$count = $row[0];
$cPages = ceil($count / $this->getLimit());
$sql = "SELECT id,giver,receiver,why,private,TIMESTAMPDIFF(SECOND,at,NOW()) as delta " . "FROM " . LOVE_LOVE . " " . "WHERE " . LOVE_LOVE . ".receiver = '" . $front->getUser()->getUsername() . "' " . "OR " . LOVE_LOVE . ".giver = '" . $front->getUser()->getUsername() . "' ";
$sql .= $justUser ? '' : "OR " . LOVE_LOVE . ".company_id = '" . $front->getUser()->getCompany_id() . "' ";
$sql .= $where . " " . "ORDER BY id DESC " . "LIMIT " . $l . "," . $this->getLimit();
$res = mysql_query($sql);
// Construct json for history
$this->pages = array(array($page, $cPages, number_format($loves)));
for ($i = 1; $row = mysql_fetch_assoc($res); $i++) {
$givernickname = getNickName($row['giver']);
$givernickname = !empty($givernickname) ? $givernickname : $row['giver'];
$receivernickname = getNickName($row['receiver']);
$receivernickname = !empty($receivernickname) ? $receivernickname : $row['receiver'];
$why = $row['why'];
if ($row['private']) {
$why .= " (love sent quietly)";
}
$history[] = array("id" => $row['id'], "giver" => $row['giver'], "giverNickname" => $givernickname, "receiver" => $row['receiver'], "receiverNickname" => $receivernickname, "why" => $why, "delta" => Utils::relativeTime($row['delta']));
}
return $history;
}
示例8: query
private static function query($q, $params = array())
{
if (self::$link === NULL) {
self::connect();
}
self::$numQuerys++;
$q .= self::$order;
$q .= self::$limit;
self::$order = '';
self::$limit = '';
self::$sql = $q;
self::$result = mysql_query($q, self::$link);
if (!self::$result) {
return false;
} else {
if (!is_resource(self::$result)) {
return true;
}
}
$rset = array();
while ($row = mysql_fetch_assoc(self::$result)) {
$rset[] = $row;
}
return $rset;
}
示例9: get
/**
* @inheritdoc
*/
public function get(VariableWrapper $data)
{
if (!$this->supports($data)) {
throw new \Ladybug\Exception\InvalidInspectorClassException();
}
$headers = array();
$rows = array();
$first = true;
while ($row = mysql_fetch_assoc($data->getData())) {
$rowData = array();
foreach ($row as $k => $v) {
if ($first) {
$headers[] = $k;
}
$rowData[] = $v;
}
$rows[] = $rowData;
$first = false;
}
/** @var $table TableType */
$table = $this->extendedTypeFactory->factory('table', $this->level);
$table->setHeaders($headers);
$table->setRows($rows);
$table->setTitle('MySQL resultset');
return $table;
}
示例10: __construct
function __construct()
{
$variables = new Variables();
$connect = new Connect($variables->dbHost, $variables->dbUser, $variables->dbPassword, $variables->dbName);
$result;
//receinving and striping the variables
$this->userMatricula = $connect->antiInjection(isset($_POST["tfMatricula"]) ? $_POST["tfMatricula"] : NULL);
$this->password = $connect->antiInjection(isset($_POST["tfPassword"]) ? $_POST["tfPassword"] : NULL);
$this->select = $connect->antiInjection(isset($_POST["slSelect"]) ? $_POST["slSelect"] : NULL);
if (!$connect->start()) {
echo "Impossible to start connection in Sigin.";
}
//encoding to md5 hash
$this->password = base64_encode($this->password);
if (!($result = $connect->execute("SELECT * FROM Cadastros c INNER JOIN Folhas f ON c.codigo_fol = f.codigo_fol WHERE c.matricula = '{$this->userMatricula}' AND c.senha = '{$this->password}' AND f.codigo_fol = '{$this->select}'"))) {
echo "Impossible to execute MySQL query.";
}
if ($connect->counterResult($result) > 0) {
$result = $connect->execute("SELECT * FROM Pessoal WHERE matricula = '{$this->userMatricula}'");
$row = mysql_fetch_assoc($result);
$_SESSION["user"] = $this->userMatricula;
$_SESSION["userPass"] = $this->password;
$_SESSION["nome"] = $row["nome"];
$connect->close();
header("Location: ../index.php?ok=true");
die;
}
$connect->close();
header("Location: ../index.php?ok=false");
die;
}
示例11: getUserTreeHTML
function getUserTreeHTML($id)
{
$sql = 'select `id` , `username` , `active` from `users` where id<>1 order by id;';
$rs = mysql_query($sql) or die("Unable to Execute Select query");
echo '<ul id="left-tree">';
if ($id == 1) {
$myclass = 'class="label label-info"';
} else {
$myclass = '';
}
echo '<li class="open"><i class="icon-globe"></i> <a ' . $myclass . ' href="users.php?id=1">Webmaster</a>';
echo '<ul>';
while ($row = mysql_fetch_assoc($rs)) {
echo '<li><i class="icon-user"></i> ';
if ($row["id"] == $id) {
echo '<a class="label label-info" href="users.php?id=' . $row["id"] . '"> ' . $row["username"];
} else {
echo '<a href="users.php?id=' . $row["id"] . '"> ' . $row["username"];
}
if ($row['active'] != 1) {
echo ' <i class="icon-ban-circle" title="User is not active, cannot login"></i> ';
}
echo '</a></li>';
}
echo '</ul>';
echo '</li></ul>';
}
示例12: read_db
function read_db($criteres = "")
{
global $db_vue_rm;
$sql = " SELECT id_loterie, date_creation_loterie, gain_loterie, id_gagnant_loterie,";
$sql .= "valeur_type_loterie, etat_loterie,";
$sql .= "nom_troll";
$sql .= " FROM loteries, trolls ";
$sql .= " WHERE id_gagnant_loterie = id_troll";
$sql .= $criteres;
if (!($result = mysql_query($sql, $db_vue_rm))) {
echo mysql_error();
} else {
$i = 1;
while ($row = mysql_fetch_assoc($result)) {
$this->list[$i]['id_loterie'] = $row['id_loterie'];
$this->list[$i]['date_creation_loterie'] = $row['date_creation_loterie'];
$this->list[$i]['gain_loterie'] = $row['gain_loterie'];
$this->list[$i]['id_gagnant_loterie'] = $row['id_gagnant_loterie'];
$this->list[$i]['valeur_type_loterie'] = $row['valeur_type_loterie'];
$this->list[$i]['etat_loterie'] = $row['etat_loterie'];
$this->list[$i]['nom_gagnant_loterie'] = $row['nom_troll'];
$i++;
}
}
}
示例13: BuildFlyingFleetTable
/**
* BuildFlyingFleetTable.php
*
* @version 1
* @copyright 2008 By Chlorel for XNova
*/
function BuildFlyingFleetTable()
{
global $lang;
$TableTPL = gettemplate('admin/fleet_rows');
$FlyingFleets = doquery("SELECT * FROM {{table}} ORDER BY `fleet_end_time` ASC;", 'fleets');
while ($CurrentFleet = mysql_fetch_assoc($FlyingFleets)) {
$FleetOwner = doquery("SELECT `username` FROM {{table}} WHERE `id` = '" . $CurrentFleet['fleet_owner'] . "';", 'users', true);
$TargetOwner = doquery("SELECT `username` FROM {{table}} WHERE `id` = '" . $CurrentFleet['fleet_target_owner'] . "';", 'users', true);
$Bloc['Id'] = $CurrentFleet['fleet_id'];
$Bloc['Mission'] = CreateFleetPopupedMissionLink($CurrentFleet, $lang['type_mission'][$CurrentFleet['fleet_mission']], '');
$Bloc['Mission'] .= "<br>" . ($CurrentFleet['fleet_mess'] == 1 ? "R" : "A");
$Bloc['Fleet'] = CreateFleetPopupedFleetLink($CurrentFleet, $lang['tech'][200], '');
$Bloc['St_Owner'] = "[" . $CurrentFleet['fleet_owner'] . "]<br>" . $FleetOwner['username'];
$Bloc['St_Posit'] = "[" . $CurrentFleet['fleet_start_galaxy'] . ":" . $CurrentFleet['fleet_start_system'] . ":" . $CurrentFleet['fleet_start_planet'] . "]<br>" . ($CurrentFleet['fleet_start_type'] == 1 ? "[P]" : ($CurrentFleet['fleet_start_type'] == 2 ? "D" : "L")) . "";
$Bloc['St_Time'] = date('G:i:s d/n/Y', $CurrentFleet['fleet_start_time']);
if (is_array($TargetOwner)) {
$Bloc['En_Owner'] = "[" . $CurrentFleet['fleet_target_owner'] . "]<br>" . $TargetOwner['username'];
} else {
$Bloc['En_Owner'] = "";
}
$Bloc['En_Posit'] = "[" . $CurrentFleet['fleet_end_galaxy'] . ":" . $CurrentFleet['fleet_end_system'] . ":" . $CurrentFleet['fleet_end_planet'] . "]<br>" . ($CurrentFleet['fleet_end_type'] == 1 ? "[P]" : ($CurrentFleet['fleet_end_type'] == 2 ? "D" : "L")) . "";
if ($CurrentFleet['fleet_mission'] == 15) {
$Bloc['Wa_Time'] = date('G:i:s d/n/Y', $CurrentFleet['fleet_stay_time']);
} else {
$Bloc['Wa_Time'] = "";
}
$Bloc['En_Time'] = date('G:i:s d/n/Y', $CurrentFleet['fleet_end_time']);
$table .= parsetemplate($TableTPL, $Bloc);
}
return $table;
}
示例14: validate
public function validate()
{/*{{{*/
$msg = '';
foreach ($this->dbreads as $dbread){
$link = mysql_connect($dbread['host'], $this->account['user'], $this->account['pass']);
$res = mysql_query('show slave status', $link);
$row = mysql_fetch_assoc($res);
if (empty($row)) {
$msg .= $dbread['host'].' can\'t be connected;';
} else if ($this->max < $row['Seconds_Behind_Master']) {
error_log("\n".date('Y-m-d H:i:s').":\n".print_r($row, true), 3, '/tmp/db.log');
$msg .= $dbread['host'].' delay '.$row['Seconds_Behind_Master'].';';
} else if ('' != $row['Last_Error']) {
$msg .= $dbread['host'].' has error!';
} else if ('Yes' != $row['Slave_IO_Running'] || 'Yes' != $row['Slave_SQL_Running']) {
$msg .= $dbread['host'].' has repl error!';
} else if ('' != $row['Last_IO_Error']) {
$msg .= $dbread['host'].' has io error!';
} else if ('' != $row['Last_SQL_Error']) {
$msg .= $dbread['host'].' has sql error!';
}
mysql_close($link);
}
return $msg;
}/*}}}*/
示例15: query
function query($sql, $type = '')
{
if (defined('SHOW_SQL')) {
global $_SGLOBAL;
$sqlstarttime = $sqlendttime = 0;
$mtime = explode(' ', microtime());
$sqlstarttime = number_format($mtime[1] + $mtime[0] - $_SGLOBAL['supe_starttime'], 6) * 1000;
echo $sql . '<br>';
}
$func = $type == 'UNBUFFERED' && @function_exists('mysql_unbuffered_query') ? 'mysql_unbuffered_query' : 'mysql_query';
if (!($query = $func($sql, $this->link)) && $type != 'SILENT') {
$this->halt('MySQL Query Error', $sql);
}
if (defined('SHOW_SQL')) {
$mtime = explode(' ', microtime());
$sqlendttime = number_format($mtime[1] + $mtime[0] - $_SGLOBAL['supe_starttime'], 6) * 1000;
$sqltime = round($sqlendttime - $sqlstarttime, 3);
echo $sqltime . '<br>';
$explain = array();
$info = mysql_info();
if ($query && preg_match("/^(select )/i", $sql)) {
$explain = mysql_fetch_assoc(mysql_query('EXPLAIN ' . $sql, $this->link));
}
$_SGLOBAL['debug_query'][] = array('sql' => $sql, 'time' => $sqltime, 'info' => $info, 'explain' => $explain);
}
$this->querynum++;
return $query;
}