本文整理汇总了PHP中mysql_data_seek函数的典型用法代码示例。如果您正苦于以下问题:PHP mysql_data_seek函数的具体用法?PHP mysql_data_seek怎么用?PHP mysql_data_seek使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mysql_data_seek函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
public function execute($sql, $table_page, $url = null, $result_per_page = 20, $adjacents = 4)
{
if ($url == null) {
$url = $_SERVER['REQUEST_URI'];
}
$uri_parts = explode('?', $url);
$url = $uri_parts[0] . "?";
$page = isset($_GET["page"]) ? $_GET["page"] : 1;
if ($page <= 0) {
$page = 1;
}
// connect to your DB:
$link_id = mysql_connect(DB_HOST, DB_USER, DB_PASS) or die(mysql_error());
mysql_select_db(DB_NAME, $link_id);
// select appropriate results from DB:
$result = mysql_query($sql, $link_id);
// count total number of appropriate listings:
$tcount = mysql_num_rows($result);
// count number of pages:
$tpages = $tcount ? ceil($tcount / $result_per_page) : 1;
// total pages, last page number
$count = 0;
$i = ($page - 1) * $result_per_page;
while ($count < $result_per_page && $i < $tcount) {
mysql_data_seek($result, $i);
$query = mysql_fetch_array($result);
// output each row:
//echo "<p>" . $query['id'] . ", " . $query['title'] . "</p>\n";
require $table_page;
$i++;
$count++;
}
//It create the page sequence at the bottom of the result.
echo $this->paginate_one($url, $page, $tpages, $adjacents);
}
示例2: createCelularInput
function createCelularInput($celularesMasPopulares, $selectName, $label)
{
mysql_data_seek($celularesMasPopulares, 0);
echo "<tr><td colspan='3'> </td></tr>";
echo "<tr>";
echo "\t<td width='20%'>" . $label . "</td>";
echo "\t<td width='30%'>";
echo "\t\t<select name='" . $selectName . "' id='" . $selectName . "' input='" . $inputName . "'>";
echo "\t\t\t<option value=''>Selecciona un celular</option>";
while ($row_celularesMasPopulares = mysql_fetch_assoc($celularesMasPopulares)) {
echo "\t\t<option value='" . $row_celularesMasPopulares['id_celular'] . "' >" . $row_celularesMasPopulares['nombre'] . "</option>";
}
echo " </select>";
echo " </td>";
echo " <td width='40%'>";
echo "\t\t<label for='" . $selectName . "_precio_12m'>Precio 12m:</label>";
echo "\t\t<input type='text' id='" . $selectName . "_precio_12m' name='" . $selectName . "_precio_12m' value=''/>";
echo "\t\t<label for='" . $selectName . "_precio_18m'>Precio 18m:</label>";
echo " \t<input type='text' id='" . $selectName . "_precio_18m' name='" . $selectName . "_precio_18m' value=''/>";
echo "\t\t<label for='" . $selectName . "_precio_24m'>Precio 24m:</label>";
echo " \t<input type='text' id='" . $selectName . "_precio_24m' name='" . $selectName . "_precio_24m' value=''/>";
echo "\t\t<label for='" . $selectName . "_precio_prepago'>Precio Prepago:</label>";
echo " \t<input type='text' id='" . $selectName . "_precio_prepago' name='" . $selectName . "_precio_prepago' value=''/>";
echo "\t</td>";
echo "</tr>";
}
示例3: display_all_music
function display_all_music()
{
$date_query = "SELECT date FROM music WHERE deleted = 'n' AND date > CURDATE() - INTERVAL 6 MONTH GROUP BY date ORDER BY date DESC";
$date_result = mysql_query($date_query);
if (!$date_result) {
die('No results in database.');
}
$music_query = "SELECT * FROM music WHERE deleted = 'n' ORDER BY date DESC, artist";
$music_result = mysql_query($music_query);
if (!$music_result) {
die('No results in database.');
}
echo "<dl class=\"new_music\">";
for ($i = 1; $i <= mysql_num_rows($date_result); $i++) {
$date_info = mysql_fetch_assoc($date_result);
echo "<dt>New Music Week of " . $date_info['date'] . "</dt>";
for ($j = 1; $j <= mysql_num_rows($music_result); $j++) {
$music_info = mysql_fetch_assoc($music_result);
echo "<dd>";
if ($music_info['date'] == $date_info['date'] && $music_info['url']) {
echo $music_info['artist'] . " - <a href=\"" . $music_info['url'] . "\" target=_new> " . $music_info['song'] . " </a>";
}
if ($music_info['date'] == $date_info['date'] && !$music_info['url']) {
echo $music_info['artist'] . " - " . $music_info['song'];
}
echo "</dd>";
}
mysql_data_seek($music_result, 0);
}
echo "</dl>";
}
示例4: performance
function performance($n)
{
$query = sprintf("SELECT * \n\tFROM torrents, deltas \n\tWHERE torrents.hash = '%s' \n\tAND deltas.hash = '%s'\n\tORDER BY day desc", $n, $n);
$r = mysql_query($query);
$numRows = mysql_num_rows($r);
$numRows = $numRows - 1;
mysql_data_seek($r, 0);
$latest = mysql_fetch_assoc($r);
mysql_data_seek($r, $numRows);
$earliest = mysql_fetch_assoc($r);
$latestDay = strtotime($latest['day']);
$earliestDay = strtotime($earliest['day']);
$duration = $latestDay - $earliestDay;
$duration = round($duration / 60 / 60 / 24, 2);
if ($latest['down'] == 0) {
$ratio = 0;
} else {
$ratio = round($latest['up'] / $latest['down'], 2);
}
if ($duration == 0) {
$performance = 0;
} else {
$performance = round($ratio / $duration, 2);
}
$name = $latest['name'];
$hash = $latest['hash'];
$whitelist = $latest['whitelist'];
$seeders = $latest['seeders'];
$tracker = $latest['tracker'];
$deletion = $latest['dateofdeletion'];
$data = array($performance, $duration, $ratio, $name, $hash, $whitelist, $seeders, $latest['day'], $tracker, $deletion);
return $data;
}
示例5: traverse
/**
* List multi-level categories
* @param int $root
* @param int $depth
* @param resource $sql
* @param string $field
* @param int $parent
* @return string
*/
function traverse($root, $depth, $sql, $field, $parent = 0)
{
$row = 0;
$id = $field['id'];
$name = $field['name'];
$field_parent = $field['parent'];
$t = '';
while ($acat = mysql_fetch_array($sql)) {
if ($acat[$field_parent] == $root) {
$s = $parent == $acat[$id] ? 'selected="selected"' : '';
$t .= "<option value='" . $acat[$id] . "' {$s}>";
$j = 0;
while ($j < $depth) {
$t .= "-";
$j++;
}
if ($depth > 0) {
$t .= "-";
}
$t .= $acat[$name] . "</option>";
@mysql_data_seek($sql, 0);
$t .= traverse($acat[$id], $depth + 1, $sql, $field, $parent);
}
$row++;
@mysql_data_seek($sql, $row);
}
return $t;
}
示例6: 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;
}
示例7: printout
public function printout($width)
{
if (isset($this->res) && mysql_num_rows($this->res) > 0) {
mysql_data_seek($this->res, 0);
$num = mysql_num_fields($this->res);
echo "<table border=l align='center' width='" . $width . "'>";
echo "<tr>";
for ($i = 0; $i < $num; $i++) {
echo "<th>";
echo mysql_field_name($this->res, $i);
echo "</th>";
}
echo "</tr>";
while ($row = mysql_fetch_row($this->res)) {
echo "<tr>";
foreach ($row as $elem) {
echo "<td>{$elem}</td>";
}
echo "</tr>";
}
echo "</table>";
} else {
echo "There is nothing to print!<BR>";
}
}
示例8: data_seek
public function data_seek($pointer)
{
if (empty($this->result)) {
die("You must run query first");
}
return mysql_data_seek($this->result, $pointer);
}
示例9: display_alternative_cell
/**
* Display alternative table cell
* @param $secondary_result mysql result of all secondary alternatives
* $alternative type the resource type of the alternative to display. Must be one of the values in resource_types.type_id
* $content_id used to pass into file_manager/index.php
* $ps used to pass into file_manager/index.php
* @return html of the table cell "<td>...</td>"
*/
function display_alternative_cell($secondary_result, $alternative_type, $content_id, $pid, $td_header_id)
{
global $content_row;
$found_alternative = false;
echo ' <td headers="' . $td_header_id . '">' . "\n";
if (mysql_num_rows($secondary_result) > 0) {
mysql_data_seek($secondary_result, 0);
// move the mysql result cursor back to the first row
while ($secondary_resource = mysql_fetch_assoc($secondary_result)) {
if ($secondary_resource['type_id'] == $alternative_type) {
echo ' <div id="' . $pid . '_' . $alternative_type . '">' . "\n";
echo ' <a href="' . $secondary_resource['secondary_resource'] . '" title="' . _AT('new_window') . '" target="_new">' . get_display_filename($secondary_resource['secondary_resource']) . '</a><br />' . "\n";
echo ' <a href="#" onclick="ATutor.poptastic(\'' . AT_BASE_HREF . 'mods/_core/file_manager/index.php?framed=1' . SEP . 'popup=1' . SEP . 'cp=' . $content_row['content_path'] . SEP . 'cid=' . $content_id . SEP . 'pid=' . $pid . SEP . 'a_type=' . $alternative_type . '\');return false;" title="' . _AT('new_window') . '">' . "\n";
echo ' <img src="' . AT_BASE_HREF . 'images/home-tests_sm.png" border="0" title="' . _AT('alter') . '" alt="' . _AT('alter') . '" />' . "\n";
echo ' </a>' . "\n";
echo ' <a href="#" onclick="removeAlternative(\'' . $content_row['content_path'] . '\', ' . $content_id . ',' . $pid . ',' . $alternative_type . ');return false;">' . "\n";
echo ' <img src="' . AT_BASE_HREF . 'images/icon_delete.gif" border="0" title="' . _AT('remove') . '" alt="' . _AT('remove') . '" />' . "\n";
echo ' </a>' . "\n";
echo ' </div>' . "\n";
$found_alternative = true;
break;
}
}
}
if (!$found_alternative) {
echo ' <div id="' . $pid . '_' . $alternative_type . '">' . "\n";
echo ' <input type="button" value="' . _AT('add') . '" title="' . _AT('new_window') . '" onclick="ATutor.poptastic(\'' . AT_BASE_HREF . 'mods/_core/file_manager/index.php?framed=1' . SEP . 'popup=1' . SEP . 'cp=' . $content_row['content_path'] . SEP . 'cid=' . $content_id . SEP . 'pid=' . $pid . SEP . 'a_type=' . $alternative_type . '\');return false;" />' . "\n";
echo ' </div>' . "\n";
}
echo ' </td>' . "\n";
}
示例10: cargo_obtener_para__vista_cargo_amigable
function cargo_obtener_para__vista_cargo_amigable(&$r)
{
if (!mysql_num_rows($r)) {
return false;
}
$fecha_min = '99999999';
$fecha_max = '00000000';
$arrBuffer = array();
$buffer = '<table class="tfija t100">';
$buffer .= '<tr><th>Cargo</th><th>Fecha de inicio</th><th>Fecha Fin</th></tr>';
while ($f = mysql_fetch_assoc($r)) {
$arrBuffer[] = array('leyenda' => $f['cargo'], 'fecha_inicio' => $f['fecha_inicio'], 'fecha_fin' => $f['fecha_fin'], 'fecha_inicio_formato' => $f['fecha_inicio_formato'], 'fecha_fin_formato' => $f['fecha_fin_formato'], 'flag_cese' => $f['flag_cese'], 'titulo' => $f['cargo']);
$fecha_minima = date('Ym01', strtotime($f['fecha_inicio']));
$fecha_maxima = date('Ymd', strtotime($f['fecha_fin']));
$fecha_min = min($fecha_min, $fecha_minima);
$fecha_max = max($fecha_max, $fecha_maxima);
if (!$f['flag_cese'] && date('Ymd', strtotime($f['fecha_fin'])) == date('Ymd')) {
$f['fecha_fin_formato'] = 'a la fecha';
}
$buffer .= sprintf('<tr><td>%s</td><td>%s</td><td>%s</td></tr>', $f['cargo'], $f['fecha_inicio_formato'], $f['fecha_fin_formato']);
}
$buffer .= '</table>';
mysql_data_seek($r, 0);
$f = mysql_fetch_assoc($r);
$tabla = '<h2>Gráfico de antecedente de cargos laborales en ' . $f['razon_social'] . '</h2>';
mysql_data_seek($r, 0);
$tabla .= ui_timeline($arrBuffer);
return $buffer . $tabla;
}
示例11: constructTable
function constructTable()
{
$result = $this->getCourseTuples();
$numRows = mysql_num_rows($result);
//mysql_num_rows
echo "<div id=\"tabs\">" . "<ul>";
for ($i = 0; $i < $numRows; $i++) {
$row = mysql_fetch_array($result);
echo "<li><a href=\"#tabs-" . $i . "\">" . $row[1] . "</a></li>";
}
mysql_data_seek($result, 0);
//Resetting Pointer
echo "</ul>";
for ($i = 0; $i < $numRows; $i++) {
$row = mysql_fetch_array($result);
echo "<div id=\"tabs-" . $i . "\">" . "<p id=\"p_feedback\"> Course Selected ---> " . $row[1] . "</div>";
echo "<input type=\"hidden\" id=\"hidden_courseID{$i}\" value=\"{$row[0]}\" />";
}
echo "<input type=\"hidden\" id=\"hidden_courseTabIndex\" value=\"0\" />";
echo "<div id=\"div_subjectAjaxFiller\" style=\"float: left; width=75%\">\n Placeholder for Subjects\n </div>";
$this->initHiddenElements();
$this->addBreaks(18);
$this->initBackButton();
$this->addBreaks(5);
echo "</div>";
}
示例12: run
/**
* Standard modular run function.
*
* @return tempcode Results
*/
function run()
{
$out = new ocp_tempcode();
$tables = $GLOBALS['SITE_DB']->query_select('db_meta', array('DISTINCT m_table'));
if (count($GLOBALS['SITE_DB']->connection_write) > 4) {
$GLOBALS['SITE_DB']->connection_write = call_user_func_array(array($GLOBALS['SITE_DB']->static_ob, 'db_get_connection'), $GLOBALS['SITE_DB']->connection_write);
_general_db_init();
}
list($db, $db_name) = $GLOBALS['SITE_DB']->connection_write;
mysql_select_db($db_name, $db);
foreach ($tables as $table) {
if ($table['m_table'] == 'sessions') {
continue;
}
// HEAP, so can't be repaired
$table = get_table_prefix() . $table['m_table'];
// Check/Repair
$result = mysql_query('CHECK TABLE ' . $table . ' FAST', $db);
echo mysql_error($db);
mysql_data_seek($result, mysql_num_rows($result) - 1);
$status_row = mysql_fetch_assoc($result);
if ($status_row['Msg_type'] != 'status') {
$out->attach(paragraph(do_lang_tempcode('TABLE_ERROR', escape_html($table), escape_html($status_row['Msg_type']), array(escape_html($status_row['Msg_text']))), 'dfsdgdsgfgd'));
$result2 = mysql_query('REPAIR TABLE ' . $table, $db);
mysql_data_seek($result2, mysql_num_rows($result2) - 1);
$status_row_2 = mysql_fetch_assoc($result2);
$out->attach(paragraph(do_lang_tempcode('TABLE_FIXED', escape_html($table), escape_html($status_row_2['Msg_type']), array(escape_html($status_row_2['Msg_text']))), 'dfsdfgdst4'));
}
// Optimise
mysql_unbuffered_query('OPTIMIZE TABLE ' . $table, $db);
}
return $out;
}
示例13: query_to_csv
function query_to_csv($query, $filename, $attachment = false, $headers = true)
{
if ($attachment) {
// send response headers to the browser
header('Content-Type: text/csv');
header('Content-Disposition: attachment;filename=' . $filename);
$fp = fopen('php://output', 'w');
} else {
$fp = fopen($filename, 'w');
}
$result = mysql_query($query) or die(mysql_error());
if ($headers) {
// output header row (if at least one row exists)
$row = mysql_fetch_assoc($result);
if ($row) {
fputcsv($fp, array_keys($row));
// reset pointer back to beginning
mysql_data_seek($result, 0);
}
}
while ($row = mysql_fetch_assoc($result)) {
fputcsv($fp, $row);
}
fclose($fp);
}
示例14: fetchRow
function fetchRow($rownum = null)
{
if ($rownum !== null) {
mysql_data_seek($this->db_result, $rownum);
}
return mysql_fetch_array($this->db_result);
}
示例15: query
public function query($vbe571b25caf2bbed46f6e47182670bf7, $v3ede331cca63faafb68a34acb42767c6 = false)
{
if (!$this->open()) {
return false;
}
$vbe571b25caf2bbed46f6e47182670bf7 = trim($vbe571b25caf2bbed46f6e47182670bf7, " \t\n");
if (defined('SQL_QUERY_DEBUG') && SQL_QUERY_DEBUG) {
echo $vbe571b25caf2bbed46f6e47182670bf7, "\r\n";
}
if (strtoupper(substr($vbe571b25caf2bbed46f6e47182670bf7, 0, 6)) != "SELECT" || defined('MYSQL_DISABLE_CACHE')) {
$result = mysql_query($vbe571b25caf2bbed46f6e47182670bf7, $this->conn);
if ($this->errorOccured()) {
throw new databaseException($this->errorDescription($vbe571b25caf2bbed46f6e47182670bf7));
}
return $result;
}
$v0800fc577294c34e0b28ad2839435945 = md5($vbe571b25caf2bbed46f6e47182670bf7);
if (isset($this->queryCache[$v0800fc577294c34e0b28ad2839435945]) && $v3ede331cca63faafb68a34acb42767c6 == false) {
$result = $this->queryCache[$v0800fc577294c34e0b28ad2839435945][0];
if ($this->queryCache[$v0800fc577294c34e0b28ad2839435945][1]) {
mysql_data_seek($result, 0);
}
} else {
$result = mysql_query($vbe571b25caf2bbed46f6e47182670bf7, $this->conn);
if ($this->errorOccured()) {
$this->queryCache[$v0800fc577294c34e0b28ad2839435945] = false;
throw new databaseException($this->errorDescription($vbe571b25caf2bbed46f6e47182670bf7));
} else {
if (SQL_QUERY_CACHE) {
$this->queryCache[$v0800fc577294c34e0b28ad2839435945] = array($result, mysql_num_rows($result));
}
}
}
return $result;
}