close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

show all rows from database table as default

Thread began 4/28/2016 8:39 am by s.joiner74419001 | Last modified 5/12/2016 11:35 am by Ray Borduin | 2361 views | 15 replies |

s.joiner74419001

show all rows from database table as default

I have the following record set which I'm using to view data from a database table with url variables and form variables.

$beginsB_rsMembersList = "-1";
if (isset($_GET['surname'])) {
$beginsB_rsMembersList = $_GET['surname'];
}
$estateName_rsMembersList = "-1";
if (isset($_POST['estate_name'])) {
$estateName_rsMembersList = $_POST['estate_name'];
}
$streetName_rsMembersList = "-1";
if (isset($_POST['street_address'])) {
$streetName_rsMembersList = $_POST['street_address'];
}
$FirstNameBegins_rsMembersList = "-1";
if (isset($_GET['first_name'])) {
$FirstNameBegins_rsMembersList = $_GET['first_name'];
}
mysql_select_db($database_LA, $LA);
$query_rsMembersList = sprintf("SELECT members.members_id, members.app_date, members.first_name, members.surname, members.property_id, properties.property_id, properties.estate_name, properties.street_address FROM members, properties WHERE (members.property_id = properties.property_id) AND (members.surname LIKE %s OR members.first_name LIKE %s OR properties.estate_name = %s OR properties.street_address = %s)", GetSQLValueString($beginsB_rsMembersList . "%", "text"),GetSQLValueString($FirstNameBegins_rsMembersList . "%", "text"),GetSQLValueString($estateName_rsMembersList, "text"),GetSQLValueString($streetName_rsMembersList, "text"));
setQueryBuilderSource($query_rsMembersList,$WADA_Sort_1,false);
$rsMembersList = mysql_query($query_rsMembersList, $LA) or die(mysql_error());
$row_rsMembersList = mysql_fetch_assoc($rsMembersList);
$totalRows_rsMembersList = mysql_num_rows($rsMembersList);

The problem Ive got is I want all results from table to show as default when a user first enters the web page.

Help Please.

Ive attached the full page.

Thanks in advance

Attached Files
members-list.php
Sign in to reply to this post

Ray BorduinWebAssist

Use DataAssist Search instead of parameters in your SQL to do your filter and it will automatically show all results when no filters are applied.

Sign in to reply to this post
Did this help? Tips are appreciated...

s.joiner74419001

Thanks Ray, But I am unfamiliar with the Data Search Feature, consequently I am unsure what to do with this. can you give me some pointers as how I would adjust what I already have to achieve this. I have had a quick play with it by removing the parameters and adjusting the SQL so the results are built on the relational value of 'members_id' from the two tables, which returns all results. But when adding a 'Data Search' server behaviour I am not sure what filter settings I need to use and how I would build the form that selects the options to filter the results.

Thanks in advance.

Steve

Sign in to reply to this post

Ray BorduinWebAssist

You remove all parameters from the results page so that it returns all results.

Then you apply the DataAssist Search server behavior to the results page and specify the columns and fields to search against. One row per field on the first page joined by OR to match your current search.

Sign in to reply to this post
Did this help? Tips are appreciated...

s.joiner74419001

Thanks for your reply Ray. I have had another go with your input but still can't get it to work.
Firstly I am attempting this with the search and results on the same page. Assuming the is possible
Here's my record set..

<?php
mysql_select_db($database_LA, $LA);
$query_rsMembersList = "SELECT members.members_id, members.app_date, members.first_name, members.surname, members.property_id, properties.property_id, properties.estate_name, properties.street_address FROM members, properties WHERE members.property_id = properties.property_id";
setQueryBuilderSource($query_rsMembersList,$WADbSearch1,false);
setQueryBuilderSource($query_rsMembersList,$WADA_Sort_1,false);
$rsMembersList = mysql_query($query_rsMembersList, $LA) or die(mysql_error());
$row_rsMembersList = mysql_fetch_assoc($rsMembersList);
$totalRows_rsMembersList = mysql_num_rows($rsMembersList);

I want to search the following ways:

- By first letter of 'first_name'
- By first letter of 'surname'
- By 'estate_name'
- By 'street_address'

Before I was using url with parameters to hold the values for 'first letter of first_name and surname' such as:

<a class="btn btn-default" role="button" href="members-list-t.php?first_name=A">A</a>
<a class="btn btn-default" role="button" href="members-list-t.php?surname=A">A</a>

I would use one of these for every letter of the alphabet.

For the searches by 'estate_name and street_address' I was using forms with a select list such as:

<form method="post" name="select-member-by-estate" id="select-member-by-estate" action="">
<div class="form-group">
<select class="form-control" id="estate_name" name="estate_name">
// repeat region
<option value="<?php echo $row_rsProperty['estate_name']; ?>"><?php echo $row_rsProperty['estate_name']; ?></option>
// end repeat region
</select>
<input name="submit-member-choice-a" class="btn btn-default" type="submit" value="Select">
</form>

So far I've tried to use the forms with the data search behaviour but without success. Ive attached some screen shots of the Data Search settings and the page. Can you see where I am going wrong?

Thanks in advance.

Sign in to reply to this post

Ray BorduinWebAssist

Please attach a copy of the page and I'll take a look.

Sign in to reply to this post
Did this help? Tips are appreciated...

s.joiner74419001

Hi Ray.

Page attached,

Many thanks.

Attached Files
members-list-t.php
Sign in to reply to this post

Ray BorduinWebAssist

A few things. First, the search code it too low. It needs to be above the recordset. Move lines 157-197 up to after line 121.

Then you have separate forms for the two select lists. Make sure all form fields for your search are in a single form, and the form submit button for that form should be named "submit-member-choice-a" since that is the trigger you are using for your search.

Sign in to reply to this post
Did this help? Tips are appreciated...

s.joiner74419001

I moved the search code to that position because as soon as I place it at line 121 I get the following error:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '0=0' at line 1.

Whats going wrong here?

Sign in to reply to this post

Ray BorduinWebAssist

Change this line:
$WADbSearch1_DefaultWhere = "0=0";

to:
$WADbSearch1_DefaultWhere = "";

Sign in to reply to this post
Did this help? Tips are appreciated...
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...