本文整理汇总了PHP中sql_fetchrow函数的典型用法代码示例。如果您正苦于以下问题:PHP sql_fetchrow函数的具体用法?PHP sql_fetchrow怎么用?PHP sql_fetchrow使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sql_fetchrow函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: preset_show_all_presets
function preset_show_all_presets($user_id)
{
assert(is_numeric($user_id));
echo "<table align=center widht=75%>\n";
echo " <tr class=wb>\n";
echo " <th>Preset name</th>\n";
echo " <th>Distance</th>\n";
echo " <th>Angle</th>\n";
echo " <th> </th>\n";
echo " </tr>\n";
// Get all presets
$result = sql_query("SELECT * FROM g_presets WHERE user_id=" . $user_id);
while ($preset = sql_fetchrow($result)) {
echo " <tr class=bl>\n";
echo " <td> " . $preset['name'] . " </td>\n";
echo " <td> " . $preset['distance'] . " </td>\n";
echo " <td> " . $preset['angle'] . " </td>\n";
echo " <td> [ <a href=vesselpreset.php?cmd=" . encrypt_get_vars("delete") . "&uid=" . encrypt_get_vars($user_id) . "&pid=" . encrypt_get_vars($preset['id']) . ">Delete</a> ] </td>\n";
echo " </tr>\n";
}
// And add room to create a new one...
echo " <tr class=bl>\n";
form_start();
echo " <input type=hidden name=cmd value=" . encrypt_get_vars("create") . ">\n";
echo " <input type=hidden name=uid value=" . encrypt_get_vars($user_id) . ">\n";
echo " <td><input type=text name=ne_name size=20 maxlength=20></td>\n";
echo " <td><input type=text name=ne_distance size=6 maxlength=6></td>\n";
echo " <td><input type=text name=ne_angle size=7 maxlength=7></td>\n";
echo " <td><input type=submit name=name=submit value=Add></td>\n";
form_end();
echo " </tr>\n";
echo "</table>\n";
}
示例2: csl_create_array
function csl_create_array($result, $colnumber)
{
assert(isset($result));
assert(isset($colnumber));
// Make array
$tmp = array();
// Explode all rows into the tmp-array
while ($row = sql_fetchrow($result)) {
// If it's not an empty string, place a comma after the string if there isn't one already...
$char = substr($row[$colnumber], -1);
if ($row[$colnumber] != "" and $char != ",") {
$row[$colnumber] = $row[$colnumber] . ",";
}
$tmp = array_merge($tmp, explode(",", $row[$colnumber]));
}
// This function makes sure we start at row 0 again. This is needed
// so we can make a second call to explode_array without having to
// do a whole query again...
@mysql_data_seek($result, 0);
// Since last char is a comma, last entry after explode is bogus
// echo "CSL_CREATE_ARRAY BEFORE: "; print_r($tmp); echo "<br>\n";
if (end($tmp) == "") {
array_pop($tmp);
}
reset($tmp);
// echo "CSL_CREATE_ARRAY AFTER : "; print_r($tmp); echo "<br>\n";
// And return
return $tmp;
}
示例3: UserList
function UserList()
{
//IF(tahapan_tes='1', 'Kraeplin', IF(tahapan_tes='2', 'PAPI', IF(tahapan_tes='3', 'DISC', IF(tahapan_tes='4', 'WPT', 'Completed')))) AS tahapan
$UserQuery = "SELECT tanggal_tes, no_ktp, nama_peserta, CONCAT(usia ,' Tahun') AS usia, posisi, tahapan_tes,\n\t\t\t\t\t\tIF(tahapan_tes='1', 'WPT', IF(tahapan_tes='2', 'PAPI', IF(tahapan_tes='3', 'DISC', IF(tahapan_tes='4', 'Kraeplin', 'Completed')))) AS tahapan\n\t\t\t\t\t\tFROM USER ";
$UserQuery .= " ORDER BY tanggal_tes DESC ";
$stmt = sql_query($UserQuery);
$content = '<div id="title" align="center" style="font-weight:bold; font-size:23px;">Data Peserta</div><br /><br /><br />
<div id="body" align="center" style="width: 900px; margin: auto;">
<table width="900px" class="display" id="tableatendee" >
<thead>
<tr align="center">
<th style="text-align:center;">Tanggal Tes</th>
<th style="text-align:center;">No. KTP</th>
<th style="text-align:center;">Nama Peserta</th>
<th style="text-align:center;">Usia</th>
<th style="text-align:center;">Posisi yang<br />Dilamar</th>
<th style="text-align:center;">Tahapan<br />Tes</th>
<th style="text-align:center;">Tindakan</th>
</tr></thead>';
$content .= '<tbody>';
$i = 0;
while ($row = sql_fetchrow($stmt)) {
$i++;
$content .= "<tr><td align=\"center\">" . getDMYFormatDate($row['tanggal_tes']) . "</td>\n\t\t\t\t\t\t<td align=\"center\">" . $row['no_ktp'] . "</td>\n\t\t\t\t\t\t<td align=\"center\">" . $row['nama_peserta'] . "</td>\n\t\t\t\t\t\t<td align=\"center\">" . $row['usia'] . "</td>\n\t\t\t\t\t\t<td align=\"center\">" . $row['posisi'] . "</td>\n\t\t\t\t\t\t<td align=\"center\">" . $row['tahapan'] . "</td>";
$content .= "<td style='text-align:center'>";
$content .= UserAction($row['no_ktp'], $row['tahapan_tes']);
$content .= "</td>";
$content .= "</tr>";
}
// if($i=='0') $content .= '<tr><td colspan="9" class="fb12" align="center" bgcolor="#d4e8f6">Data tidak ditemukan</td></tr>';
$content .= '</tbody>';
$content .= '</table><br><br></div>';
echo $content;
}
示例4: scan_area
function scan_area($sector, $range)
{
$result = sql_query("SELECT * FROM s_sectors WHERE id={$sector}");
$sector = sql_fetchrow($result);
echo "<table align=center border=1>\n";
echo " <tr><th colspan=4>Scanning from origin " . $sector['name'] . " ( " . $sector['distance'] . " / " . $sector['angle'] . " ) @ " . $range . " lightyears</th></tr>\n";
echo " <tr><td>Name</td><td>Race</td><td>D / A</td><td>Range</td></tr>\n";
$result = sql_query("SELECT * FROM g_vessels ORDER BY user_id");
while ($vessel = sql_fetchrow($result)) {
$result2 = sql_query("SELECT * FROM s_species WHERE user_id = " . $vessel['user_id']);
$race = sql_fetchrow($result2);
if ($vessel['sector_id'] == 0) {
$distance = calc_distance($sector['distance'], $sector['angle'], $vessel['distance'], $vessel['angle']);
if ($distance <= $range) {
echo "<tr><td>" . $vessel['name'] . " (" . $vessel['sector_id'] . ")</td><td>" . $race['name'] . "</td><td>" . $vessel['distance'] . " / " . $vessel['angle'] . "</td><td>" . $distance . "</td></tr>\n";
}
} else {
$result2 = sql_query("SELECT * FROM s_sectors WHERE id=" . $vessel['sector_id']);
$vessel_sector = sql_fetchrow($result2);
$distance = calc_distance($sector['distance'], $sector['angle'], $vessel_sector['distance'], $vessel_sector['angle']);
if ($distance <= $range) {
echo "<tr><td>" . $vessel['name'] . " (" . $vessel['sector_id'] . ")</td><td>" . $race['name'] . "</td><td>SECTOR: " . $vessel_sector['distance'] . " / " . $vessel_sector['angle'] . "</td><td>" . $distance . "</td></tr>\n";
}
}
}
print "</table>";
print "<br><br>";
return;
}
示例5: show_users
function show_users($user_id)
{
global $_GALAXY;
echo "<table border=0 align=center width=60%>\n";
// Show friends
echo "<tr><th class=white colspan=2>Friendly Races</th></tr>\n";
$result = sql_query("SELECT gu.* FROM g_users AS gu, g_knownspecies AS gks WHERE FIND_IN_SET( gu.user_id, gks.csl_friend_id ) and gks.user_id=" . $user_id);
while ($user = sql_fetchrow($result)) {
echo "<tr class=bl><td><a href=user.php?cmd=" . encrypt_get_vars("showdetail") . "&uid=" . encrypt_get_vars($user['user_id']) . ">" . $user['race'] . " Race</a></td><td> </td></tr>\n";
}
echo "<tr><td colspan=2> </td></tr>\n";
// Show neutral
echo "<tr><th class=white colspan=2>Neutral Races</th></tr>\n";
$result = sql_query("SELECT gu.* FROM g_users AS gu, g_knownspecies AS gks WHERE FIND_IN_SET( gu.user_id, gks.csl_neutral_id ) and gks.user_id=" . $user_id);
while ($user = sql_fetchrow($result)) {
echo "<tr class=bl><td><a href=user.php?cmd=" . encrypt_get_vars("showdetail") . "&uid=" . encrypt_get_vars($user['user_id']) . ">" . $user['race'] . " Race</a></td><td> </td></tr>\n";
}
echo "<tr><td colspan=2> </td></tr>\n";
// Show enemies
echo "<tr><th class=white colspan=2>Enemy Races</th></tr>\n";
$result = sql_query("SELECT gu.* FROM g_users AS gu, g_knownspecies AS gks WHERE FIND_IN_SET( gu.user_id, gks.csl_enemy_id ) and gks.user_id=" . $user_id);
while ($user = sql_fetchrow($result)) {
echo "<tr class=bl><td><a href=user.php?cmd=" . encrypt_get_vars("showdetail") . "&uid=" . encrypt_get_vars($user['user_id']) . ">" . $user['race'] . " Race</a></td><td> </td></tr>\n";
}
echo "<tr><td colspan=2> </td></tr>\n";
echo "</table>";
}
示例6: show_owned_convoys
function show_owned_convoys($user_id)
{
assert(is_numeric($user_id));
echo "<table border=1 align=center>";
echo " <tr>";
echo " <th>Convoy Name</th>";
echo " <th>Flag Ship</th>";
echo " <th>Ships</th>";
echo " <th>Status</th>";
echo " </tr>";
$result = sql_query("SELECT c.* FROM s_convoys c, s_vessels v WHERE c.vessel_id=v.id AND v.user_id=" . $user_id);
while ($convoy = sql_fetchrow($result)) {
// Get the flag ship of the convoy
$vesseltype = vessel_get_vessel_type($convoy['id']);
// Count the number of ships
$result2 = sql_query("SELECT c.* FROM s_convoys c, s_vessels v WHERE c.vessel_id=v.id AND v.user_id=" . $user_id);
$tmp = csl_create_array($result2, "vessel_ids");
$shipcount = count($tmp);
// Get the status of the convoy
$status = $convoy['status'];
echo "<tr>";
echo "<td> " . $convoy['name'] . " </td>";
echo "<td> " . $vesseltype['name'] . " </td>";
echo "<td> " . $shipcount . " </td>";
echo "<td> " . $status . " </td>";
echo "</tr>";
}
echo "</table>";
}
示例7: wormhole_show_wormhole
function wormhole_show_wormhole($wormhole_id)
{
assert(!empty($wormhole_id));
global $_GALAXY;
if (!anomaly_is_wormhole($wormhole_id)) {
return;
}
$wormhole = anomaly_get_anomaly($wormhole_id);
$sector = sector_get_sector($wormhole['sector_id']);
$race = user_get_race($wormhole['user_id']);
$result = sql_query("SELECT * FROM w_wormhole WHERE id=" . $wormhole['id']);
$dst_wormhole = sql_fetchrow($result);
if ($race == "") {
$race = "-";
}
echo "<table border=1 width=500 align=center>\n";
echo " <tr><td align=center><b><i>Sector: " . $sector['name'] . " / Anomaly: " . $wormhole['name'] . "</i></b></td></tr>\n";
echo " <tr><td>\n";
echo " <table border=0 cellpadding=0 cellspacing=0 width=100%>\n";
echo " <tr><td width=200>\n";
echo " <table border=0 cellpadding=0 cellspacing=0 width=100%>\n";
echo " <tr><th>Anomaly View</th></tr>\n";
echo " <tr><td width=100%><center><img src=\"" . $_CONFIG['URL'] . $_GALAXY['image_dir'] . "/wormholes/" . $wormhole['image'] . ".jpg\" width=150 height=150></center></td></tr>\n";
echo " <tr><th> </th></tr>\n";
echo " </table>\n";
echo " </td>\n";
echo " <td> </td>\n";
echo " <td nowrap valign=top>\n";
echo " <table border=0 cellpadding=0 cellspacing=0 width=100%>\n";
echo " <tr><td nowrap width=40%><strong>Wormhole Name </strong></td><td nowrap width=1%><b>:</b></td>\n";
if ($wormhole['unknown'] == 1) {
form_start();
echo "<td nowrap>\n";
echo " <input type=hidden name=aid value=" . encrypt_get_vars($wormhole_id) . ">\n";
echo " <input type=hidden name=cmd value=" . encrypt_get_vars("claim") . ">\n";
echo " <input type=text size=15 maxlength=30 name=ne_name>\n";
echo " <input name=submit type=submit value=\"Claim\">\n";
echo "</td>\n";
form_end();
} else {
echo "<td nowrap>" . $wormhole['name'] . "</td>\n";
}
echo " </tr>\n";
echo " <tr><td colspan=3> </td></tr>\n";
echo " <tr><td nowrap width=40%><strong>Caretaker </strong></td><td nowrap width=1%><b>:</b> </td><td nowrap>" . $race . "</td></tr>\n";
echo " <tr><td nowrap width=40%><strong>Radius </strong></td><td nowrap width=1%><b>:</b> </td><td nowrap>" . $wormhole['radius'] . " km</td></tr>\n";
echo " <tr><td nowrap width=40%><strong>Distance to sun </strong></td><td nowrap width=1%><b>:</b> </td><td nowrap>" . $wormhole['distance'] . " km (10<sup>6</sup>)</td></tr>\n";
echo " <tr><td colspan=3> </td></tr>\n";
echo " <tr><td nowrap width=40%><strong>Destination </strong></td><td nowrap width=1%><b>:</b> </td><td nowrap>" . $dst_wormhole['distance'] . " / " . $dst_wormhole['angle'] . "</td></tr>\n";
echo " <tr><td nowrap width=40%><strong>Stability </strong></td><td nowrap width=1%><b>:</b> </td><td nowrap>" . wormhole_get_wormhole_stability($dst_wormhole['next_jump']) . " </td></tr>\n";
echo " </table>\n";
echo " </td>\n";
echo " </tr>\n";
echo " </table>\n";
echo " </td>\n";
echo " </tr>\n";
echo "</table>\n";
echo "<br><br>\n";
}
示例8: help_set_template_vars
function help_set_template_vars(&$template, $prefix = "%")
{
// NOOOTIENOOOT: You see this is a REFERENCE to the object, not the object itself, since we still use PHP4.0 :(
assert(is_object($template));
$result = sql_query("SELECT * FROM perihelion.help WHERE id like '" . $prefix . "_%'");
while ($row = sql_fetchrow($result)) {
$template->assign("help_" . strtolower($row['id']), help_link($row['id']));
}
}
示例9: score_generate_scoring_table
function score_generate_scoring_table()
{
global $score_generated;
global $score;
$tables = array("resource", "exploration", "strategic", "overall");
foreach ($tables as $table) {
$result = sql_query("SELECT u.id AS user_id, u.name, s.{$table} AS points FROM perihelion.u_users AS u, perihelion.u_score AS s WHERE u.id = s.user_id ORDER BY s.{$table} DESC");
$i = 0;
while ($row = sql_fetchrow($result)) {
$i++;
$score[$table][$i] = $row;
}
}
$score_generated = true;
}
示例10: anomaly_get_anomaly
function anomaly_get_anomaly($anomaly_id)
{
assert(is_numeric($anomaly_id));
global $cache_aga;
// Check if we want info for the last userid (most of the time this is true)
if ($cache_aga == 0 or $anomaly_id != $cache_aga['id']) {
$result = sql_query("SELECT * FROM s_anomalies WHERE id=" . $anomaly_id);
$tmp = sql_fetchrow($result);
$cache_aga = array();
$cache_aga['id'] = $anomaly_id;
$cache_aga['query'] = $tmp;
return $tmp;
}
// Return cached information
return $cache_aga['query'];
}
示例11: building_get_building
function building_get_building($building_id)
{
assert(is_numeric($building_id));
global $cache_bgb;
// Check if we want info for the last userid (most of the time this is true)
if ($cache_bgb == 0 or $building_id != $cache_bgb['id']) {
$result = sql_query("SELECT * FROM s_buildings WHERE id=" . $building_id);
$tmp = sql_fetchrow($result);
$cache_bgb = array();
$cache_bgb['id'] = $building_id;
$cache_bgb['query'] = $tmp;
return $tmp;
}
// Return cached information
return $cache_bgb['query'];
}
示例12: sector_get_sector
function sector_get_sector($sector_id)
{
assert(isset($sector_id));
global $cache_sgs;
// Check if we want info for the last userid (most of the time this is true)
if ($cache_sgs == 0 or $sector_id != $cache_sgs['id']) {
$result = sql_query("SELECT * FROM s_sectors WHERE id=" . $sector_id);
$tmp = sql_fetchrow($result);
$cache_sgs = array();
$cache_sgs['id'] = $sector_id;
$cache_sgs['query'] = $tmp;
return $tmp;
}
// Return cached information
return $cache_sgs['query'];
}
示例13: warp_scheme
function warp_scheme($warp)
{
$result = sql_query("SELECT COUNT(*) AS nr FROM s_sectors");
$tmp = sql_fetchrow($result);
$count = $tmp['nr'];
if ($count > 30) {
$count = 30;
echo "WARNING: Only the first 30 sectors are viewed now!!!<br>\n";
}
$result = sql_query("SELECT * FROM s_sectors");
print "<table align=center border=1>";
print " <tr><th colspan=" . ($count + 1) . ">Warp Factor " . $warp . "</th></tr>";
print " <tr><th> </th>";
$sector_arr = array();
$result = sql_query("SELECT * FROM s_sectors");
while ($s = sql_fetchrow($result)) {
array_push($sector_arr, $s);
}
// Create top columns
reset($sector_arr);
foreach ($sector_arr as $sector) {
echo "<th> " . $sector['name'] . " </th>";
}
echo "</tr>\n";
// And create rows
reset($sector_arr);
foreach ($sector_arr as $sector) {
echo "<tr><th> " . $sector['name'] . " </th>";
for ($i = 1; $i <= $count; $i++) {
if ($sector['name'] == $sector_arr[$i - 1]['name']) {
echo "<td align=center> </td>";
} else {
$sector_ticks = calc_sector_ticks($sector['distance'], $sector['angle'], $sector_arr[$i - 1]['distance'], $sector_arr[$i - 1]['angle'], $warp);
echo "<td align=center> " . $sector_ticks . " </td>";
}
}
echo "</tr>\n";
}
print "</table>";
print "<br><br>";
}
示例14: print_users
function print_users()
{
global $_CONFIG;
global $_RUN;
// Hmm, this should be a decent mysql query which filters out the last login_time and login_date per user_id actually... :(
$user = array();
$result = sql_query("SELECT * FROM perihelion.u_access ORDER BY logout DESC");
while ($row = sql_fetchrow($result)) {
if (!array_key_exists($row['user_id'], $user)) {
$user[$row['user_id']]['user_id'] = $row['user_id'];
$user[$row['user_id']]['login'] = $row['login'];
$user[$row['user_id']]['logout'] = $row['logout'];
} else {
if ($user[$row['user_id']]['logout'] < $row['logout']) {
$user[$row['user_id']]['login'] = $row['login'];
$user[$row['user_id']]['logout'] = $row['logout'];
}
}
}
foreach ($user as $row) {
$account = user_get_perihelion_user($row['user_id']);
list($idle, $timestamp) = create_idle_time($row['logout']);
// Don't show invisible users..
if (user_is_invisible($row['user_id'])) {
continue;
}
if ($timestamp < $_CONFIG['MAX_SECONDS_IDLE']) {
$tmpvar[] = array('href' => "user.php?cmd=" . encrypt_get_vars("showdetail") . "&uid=" . encrypt_get_vars($row['user_id']), 'user' => $account['name'], 'idle' => $idle);
}
}
// Output it...
$template = new Smarty();
$template->debugging = true;
$template->assign("onlineusers", $tmpvar);
$template->display($_RUN['theme_path'] . "/whoisonline.tpl");
}
示例15: show_participated_convoys
function show_participated_convoys($_USER)
{
echo "<table border=1 align=center>";
echo " <tr><th colspan=5>All participated convoys</th></tr>";
echo " <tr>";
echo " <th>Vessel Name</th>";
echo " <th>Convoy Name</th>";
echo " <th>Flag Ship</th>";
echo " <th>Ships</th>";
echo " <th>Status</th>";
echo " </tr>";
$result = sql_query("SELECT * FROM g_vessels WHERE user_id=" . $_USER['id']);
while ($vessel = sql_fetchrow($result)) {
if ($vessel['convoy_id'] == 0) {
continue;
}
$result2 = sql_query("SELECT * FROM s_convoys WHERE id=" . $vessel['convoy_id']);
$convoy = sql_fetchrow($result2);
// Get the flag ship of the convoy
$flagvessel = vessel_get_vessel($convoy['vessel_id']);
// Count the number of ships
$result2 = sql_query("SELECT c.* FROM s_convoys c, g_vessels v WHERE c.vessel_id=v.id AND v.user_id=" . $_USER['id']);
$tmp = csl_create_array($result2, "csl_vessel_id");
$shipcount = count($tmp);
// Get the status of the convoy
$status = $convoy['status'];
echo "<tr>";
echo "<td> " . $vessel['name'] . " </td>";
echo "<td> " . $convoy['name'] . " </td>";
echo "<td> " . $flagvessel['name'] . " </td>";
echo "<td> " . $shipcount . " </td>";
echo "<td> " . $status . " </td>";
echo "</tr>";
}
echo "</table>";
}