PDA

View Full Version : Activating the filters in dynamic pages


Jimmel
10-03-2008, 09:32 AM
Hi

I have a database connected to a dreamweaver site. I am using the web hosting server to test the pages. They only use PHP. So i have set up a MySql database on their server and made two PHP pages in dreamweaver. The two pages are a search page and a results page. The database imports Ok into dreamweaver and everything connects OK. I have set up a form on the search page and the results page and connected them through both the POST and GET settings. I have also set up a list on the search page containing some of the item I wish to search for in the database. But when i click on an item in this list I only get either all the database items or none of them. I get all of the items when I have no filter settings set in the recordset in the results page. I get none of the item when I have a filter set in the recordset in the results page. I have followed the tutorials on all the offical web pages but can't seem to get the filters to work. Couls someone please let me know if they have a solution. If you need any more info just let me know.
Thanks

edbr
10-03-2008, 09:57 AM
not sure what you mean by

connected them through both the POST and GET settingsyour filter settings must be wrong, show some code

Jimmel
10-03-2008, 10:17 AM
Hi

The code for the search page form is as follows:


<form action="resultspage.php" method="get" name="formtest" id="formtest">
<label></label>
<label>list
<select name="select" size="8" multiple="multiple">
<option value="Security" <?php if (!(strcmp("Security", $_POST['formtest']))) {echo "selected=\"selected\"";} ?>>Security</option>
</select>
Send
<input name="Submit" type="submit" value="Submit" />
</label>
</form>


The code for the results page is as follows:


<form id="formtest" name="formtest" method="get" action="">
<table border="1" cellpadding="1" cellspacing="1">
<tr>
<td>Catagory</td>
<td>Company Name</td>
<td>Address</td>
<td>Town</td>
<td>County</td>
<td>BusinessPhone</td>
</tr>
<?php do { ?>
<tr>
<td><?php echo $row_Recordset1['Catagory']; ?></td>
<td><?php echo $row_Recordset1['Company Name']; ?></td>
<td><?php echo $row_Recordset1['Address']; ?></td>
<td><?php echo $row_Recordset1['Town']; ?></td>
<td><?php echo $row_Recordset1['County']; ?></td>
<td><?php echo $row_Recordset1['BusinessPhone']; ?></td>
</tr>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
</table>
</form>

Hope this make sense

edbr
10-03-2008, 10:31 AM
try this
form 1 use method post.
on your results page, set your record set filter up for post variables
on your results page you are echoing the results into a form , not sure why,
but it is not set with any action anyway just echo into a table

Jimmel
10-03-2008, 10:53 AM
Thanks for the reply. I have tried that but still the same results. In the results page recordset in the filter settings i have entered
'catogory' ' = '
'Form variable ' 'formtest'
Is the 4th box 'formtest' the problem?

Here is the revised code
Search page:


<form action="resultspage.php" method="post" name="formtest" id="formtest">
<label></label>
<label>list
<select name="select" size="8" multiple="multiple">
<option value="Security" <?php if (!(strcmp("Security", $_POST['formtest']))) {echo "selected=\"selected\"";} ?>>Security</option>
</select>
Send
<input name="Submit" type="submit" value="Submit" />
</label>
</form>


Results page:

<form id="formtest" name="formtest" method="post" action="">
<table border="1" cellpadding="1" cellspacing="1">
<tr>
<td>Catagory</td>
<td>Company Name</td>
<td>Address</td>
<td>Town</td>
<td>County</td>
<td>BusinessPhone</td>
</tr>
<?php do { ?>
<tr>
<td><?php echo $row_Recordset1['Catagory']; ?></td>
<td><?php echo $row_Recordset1['Company Name']; ?></td>
<td><?php echo $row_Recordset1['Address']; ?></td>
<td><?php echo $row_Recordset1['Town']; ?></td>
<td><?php echo $row_Recordset1['County']; ?></td>
<td><?php echo $row_Recordset1['BusinessPhone']; ?></td>
</tr>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
</table>
</form>

edbr
10-03-2008, 11:25 AM
i should thinks so . if you have a form field called formtest it will post to your results page as 4_post['formtest']
your recordset will then compare?select based on matching that againsy your database. i only see select name="select "

Jimmel
10-03-2008, 02:05 PM
Hi

It works. I put 'select' in the 4th filter box in the results page recordset instead of formtest. Simple enough answer in the end but there is no way I would not have got that myself. Thank for that, you saved me lots of time and frustration.