Jump to content

Archived

This topic is now archived and is closed to further replies.

Gill

A PHP script to refilter results?

Recommended Posts

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);

?>

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.