Yeah, we are gettign a single row each time.
The file is
hocatID (auto-increm) primary key
Hocat (varchar - index)
description (varchar)
...plus many other numeric/varchar fields.
We are looking to display a single record on a page at one time with an
option for the user to step through the file. In our current system, it's a
simple case of read next / read previous on the file. Apologies if this is
bad mailing list form, but here is the crux of the code.
The $hoCategory & $description fields are a cut-down form in html thus..
<td height="36" align="right" valign="bottom" nowrap width=100>
<font color="#000099"><b>Ho
Category</b> </font></td>
<td valign="bottom" nowrap>
<input name="hoCategory" type="text" tabindex="1"
size="4" maxlength="4" value="<? echo $hoCategory
?>">
</td>
</tr>
<tr>
<td height="28" align="right" valign="middle" nowrap>
<font
color="#000099"><b>Description</b> </font>
</td>
<td valign="middle" nowrap>
<input name="description" type="text" tabindex="2"
size="30" maxlength="30" value ="<? echo
$description?>">
</td>
..with the main code being...
<?php
function foo()
{
global $HTTP_POST_VARS;
global $hoCategory, $description;
$num1 = $HTTP_POST_VARS['mycount'];
$numargs = func_num_args(); // any args passed to this func?
if (!$numargs)
return;
$Args = func_get_args(); // if so .. get 'em
switch($Args[0])
{
case "Last": $num1 = $GLOBALS['maxRecs'] - 1; // Zero
index
break;
case "Incr": $num1++; break;
case "Decr": $num1--; break;
default: $num1 = 0; // also
handles 'First'
}
if ($num1 > $GLOBALS["maxRecs"] || $num1 < 1 || $num1 == NULL)
$num1 = 0;
$sql = "SELECT * FROM `Ho Category` LIMIT " . $num1 . ",1";
$result = mysql_query($sql, $GLOBALS["link"]) or
die("Failed on Query");
if (!mysql_num_rows($result))
{ //
No more records in the file
if ($Args[0] == "Incr" || $Args[0] == "Last")
$num1--; // undo action
else
$num1++;
}
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
$row = setVariables($row);
foreach($row as $key => $value)
$$key = $value; // copy value to key-named field/var.
}
mysql_free_result($result);
return $num1;
}
?>
- As I said, we are fumbling a bit here as we look to move towards web-based
systems.
Regards,
Colin K Heaps
-----Original Message-----
From: Jerry [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, February 19, 2003 3:01 PM
To: Colin; [EMAIL PROTECTED]
Subject: Re: Sequential read on a file
Use and id column, like an auto increment one and use that in the html you
are writing out +1 or -1 to get the next.
i.e.
"select id, X, X, X from table where id=1"
returns 1, value of X, value of X, value of X etc etc etc
then in the html use the id .
id+1
<a href="wizzyScript.php?id=2">Next</a>
need some error checking for less than 0 and finding out what the max is.
Most lightly going to be something in here :
http://www.devshed.com/Server_Side/PHP
Is it a case of one rows worth of information from the dB per page/request ?
----------
Jerry @
MetalCat
dot Net
----------
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php