Jump to content


Photo

A PHP script to refilter results?


  • Please log in to reply
1 reply to this topic

#1 Gill

Gill
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 21 November 2003 - 12:56 PM

Using: DWMX/PHP/Mysql

Hi All

First time here so im not sure who the members of this group are so hello to everyone.

Using dreamweaverMX I have inserted a recordset on my page which displays all the results from my database.

I am trying to find a php script to go on my page as a visible text hyperlink that users can click to resort/refilter the results.

ie making the current results:

$query_Recordset1 = \"SELECT * FROM books\";

which is showing ALL the results from the database table, change to show only results where name column= paperback or name column = hardback etc

i.e. allowing people to refilter the results.

below is a full copy of my page.

Can anyone tell me how to do this?

Any advice is very much appreciated
Gill
-----


<?php require_once(\'Connections/str.php\'); ?>
<?php
$maxRows_Recordset1 = 10;
$pageNum_Recordset1 = 0;
if (isset($HTTP_GET_VARS[\'pageNum_Recordset1\'])) {
$pageNum_Recordset1 = $HTTP_GET_VARS[\'pageNum_Recordset1\'];
}
$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;

mysql_select_db($database_str, $str);
$query_Recordset1 = \"SELECT * FROM books\";
$query_limit_Recordset1 = sprintf(\"%s LIMIT %d, %d\", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
$Recordset1 = mysql_query($query_limit_Recordset1, $str) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);

if (isset($HTTP_GET_VARS[\'totalRows_Recordset1\'])) {
$totalRows_Recordset1 = $HTTP_GET_VARS[\'totalRows_Recordset1\'];
} else {
$all_Recordset1 = mysql_query($query_Recordset1);
$totalRows_Recordset1 = mysql_num_rows($all_Recordset1);
}
$totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;
?>
<html>
<head>
<title>Untitled Document</title>
</head>

<body>
<table border=\"0\">
<tr>
<td>no</td>
<td>name</td>
<td>url</td>
</tr>
<?php do { ?>
<tr>
<td><?php echo $row_Recordset1[\'no\']; ?></td>
<td><?php echo $row_Recordset1[\'name\']; ?></td>
<td><?php echo $row_Recordset1[\'url\']; ?></td>
</tr>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
</table>

</body>
</html>
<?php
mysql_free_result($Recordset1);
?>

#2 Gill

Gill
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 25 November 2003 - 02:25 PM

:(




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users