Jump to content

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

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.