Re: Select a range around a specific row Very cool. I can definitely run with that. Thanks so much for the help
(and thanks to Bill Karwin as well).
wbh
strawberry wrote:
> There might be a couple of mistakes in the previous script. Well, there
> usually are! I've mucked around with a tiny bit more. It's still not
> quite right - it's 1 row out I think!
> <?php
> /* Program: pos.php
> * Desc: A Point of Scale Display
> */
> //run the connection script
> include('connection/script');
> //Define all the key values Bill was talking about
>
> $mytable = table; //The data we want to use for the query
> $query = "SELECT COUNT(*) FROM $mytable;";
> $result = mysql_query($query) or die ("Couldn't perform 1st query.");
>
> //Refer to scrollbar diagram for meaning of each of the following.
> $AB = mysql_result($result,0);
> $Ap = 139;//A variable (between A & B) assigned by the user.
> $xy = 10; //A range, currently a constant
> $xp = round($xy*($Ap/$AB));
> $Ax = $Ap - $xp;
>
> //And so to the resulting query...
>
> $query = "SELECT * FROM $mytable LIMIT $xy OFFSET $Ax;";
> echo "2nd Query = $query";
> $result = mysql_query($query) or die ("Couldn't perform 2nd
> query.");
>
> //Show the results in a bit of HTML
> echo "<table>\n";
> while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
> echo "\t<tr>\n";
> foreach ($line as $col_value) {
> echo "\t\t<td>$col_value</td>\n";
> }
> echo "\t</tr>\n";
> }
>
> echo "</table>\n"
>
> ?>
> |