note 16088 added to function.echo
| From: | sean dot lathey at rotadata dot com | Date: | Tue, 16 Oct 2001 08:35:19 +0000 |
| Subject: | note 16088 added to function.echo | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-18971@lists.php.net to get a copy of this message | ||
PHP & MySQL : Placing a Range Maker for submitting to another page ( Part 1 ).
===================================================================
Created : Séan J. Lathey
Date : 16/10/2001
© Copyright 2001
$DB = your Database, $TA = your Table, $ID = index reference ( remove if not required )
*******************************************************************************
* Add this to the submitting form *
*******************************************************************************
echo "<FORM ACTION='query_en";
echo "_$TA";
echo ".phtml?DB=$DB&TA=$TA&ID=$ID' METHOD='POST'
ENCTYPE='application/x-www-form-urlencoded'> ";
blackFont (" Show records with details : ");
// Set the database table, field containing reference number & set MIN level
$UseTable="$TA";
$UseField="ni_id";
$BaseNum=9999;
echo "<select name='NumRange' size='1'
class='dropdown'>";
echo "<option value='ALL' selected> ALL </option>";
$q ="SELECT ";
$q.=" $UseField";
$q.=" ";
$q.="FROM $UseTable ";
$q.="WHERE";
$q.=" $UseField > $BaseNum ";
$q.="ORDER BY";
$q.=" $UseField ASC ";
$resultpo=mysql_query("$q");
while ($rowpo = mysql_fetch_row($resultpo))
{
$pototal=$rowpo[0];
}
// $pototal now equals the number of the last record
$q ="SELECT ";
$q.=" $UseField";
$q.=" ";
$q.="FROM $UseTable ";
$q.="WHERE";
$q.=" $UseField > $BaseNum ";
$q.="ORDER BY";
$q.=" $UseField DESC ";
$resultpo=mysql_query("$q");
// Reverse the order and set the defaults where $ViewMax sets ranges
$ViewMax=100;
$Start="10000";
$EndRange=$pototal;
while($EndRange > $ViewMax )
{
// Repeat until within a complete range, i.e. 23 = 223 - 200
$EndRange=$EndRange - $ViewMax;
}
// Set start of the last range, i.e. 200 - 223
$StartRange=$pototal - $EndRange;
echo "<option value='$StartRange - $pototal'> $StartRange - $pototal
</option>";
$NewEndRange=$StartRange;
while ($NewEndRange >= "$Start")
{
// Repeat for each of the whole ranges, i.e. 100-199 & 0 - 99
$NewEndRange=$StartRange - 1;
$StartRange=$StartRange - $ViewMax;
if($StartRange>="$Start")
{
// Make sure that the $StartRange is either the same or greater than the $Start baseline
echo "<option value='$StartRange - $NewEndRange'> $StartRange -
$NewEndRange </option>";
}
}
echo "</select>";
echo " <INPUT TYPE='hidden' NAME='UseTable'
VALUE='$UseTable'>";
echo " <INPUT TYPE='hidden' NAME='UseField'
VALUE='$UseField'>";
echo " <INPUT TYPE='hidden' NAME='BaseNum'
VALUE='$BaseNum'>";
echo " <INPUT TYPE='submit' NAME='Submit' VALUE='GO
»'>";
echo "</form>";
--
http://www.php.net/manual/en/function.echo.php
http://master.php.net/manage/user-notes.php?action=edit+16088
http://master.php.net/manage/user-notes.php?action=delete+16088
http://master.php.net/manage/user-notes.php?action=reject+16088