close ad
WARNING PC USERS: Do Not Install the DREAMWEAVER CC 2017 Update »
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Show Records If

Thread began 9/16/2009 5:05 pm by info271221 | Last modified 9/17/2009 6:15 pm by Jason Byrnes | 1955 views | 10 replies |

info271221

Show Records If

On my results page I am displaying 25 results. I would like to display only 5 results if you are not logged in. How can I accomplish this? Results / Search page is attached.
Live page: whitetaildeer_Results.php

Sign in to reply to this post

tom92909Beta Tester

In your results page there is a line that was created by DataAssist that refers to the total amount of results you want to display at a time.

php:
$maxRows_WADA<YOUR_RECORDSET_NAME> = 25;



Change the 25 to whatever number you want on that $maxRows line. In the example you attached that number is actually set to 15.

Sign in to reply to this post

Jason ByrnesWebAssist

You can also change it by double clicking on the repeat Region server behavior. This will allow you to specify the number of records to display.

Sign in to reply to this post

info271221

Show 25 Records if logged in, show 5 if not

I clearly understand how to change the # of records that display.
I need to know how to tell the page to display 25 records if logged in and only show 5 records if you are not logged in.

It is a membership benefit to see 25 records at a time verses 5. I also hid the first, last, next so that only members that are logged in can get to the next page forcing non-members to search again verses being able to see the next results.

Is it possible to display 25 records to members that are logged in and 5 to members that are not?

If so do I create another recordset that displays only 5 and another repeating region and apply show if not logged in to the new repeating region and apply show if logged in to the existing recordset and repeating region that displays 25 records.

Thank You

Sign in to reply to this post

anonymous

Yes.. the way to do this is to first make sure you have a session variable created when you authenticate the user. There's always at least one (I am sure you have user_ID for example, although I am not sure of the naming convention). For the purpose of this instruction, let's say it us "user_ID" that gets set as a session variable when someone logs in.

Now, if your site doesn't have user levels and anyone - just as long as they are logged in - is allowed to see the full 25 rows, then you just need to check that the session variable exists.

So your code would look like this:

php:
if ($_SESSION['user_ID']) {

$maxRows_WADA<YOUR_RECORDSET_NAME> = 25; 

} else {

$maxRows_WADA<YOUR_RECORDSET_NAME> = 5; 

}



No you have created an if statement that will check for the session variable of user_ID which can only be set when someone logs in and then will display 25 records. If the variable is not set, it will only show 5.

Cheers,

Brian

Sign in to reply to this post

info271221

variable error

Now I get this error:
PHP Parse error: syntax error, unexpected '=' in D:\Websites\www.myDomain\RecordWhiteTail\whitetaildeer_Results2.php on line 132

I am using security assist for member access levels and the id is being used for the session variable. Here is the code from the helper page:
case "Logged in to member_directory":
$comparisons[0] = array(TRUE, "".((isset($_SESSION['id']))?$_SESSION['id']:"") ."", 2, "");

Below is the code on my results page:
whitetaildeer_Results2.php

<?php
$maxRows_WADAdeer = 25;
if ($_SESSION['id']) {
$maxRows_WADAdeer> = 25;

} else {

$maxRows_WADAdeerLimit> = 5;

}

$pageNum_WADAdeer = 0;
if (isset($_GET['pageNum_WADAdeer'])) {
$pageNum_WADAdeer = $_GET['pageNum_WADAdeer'];
}
$startRow_WADAdeer = $pageNum_WADAdeer * $maxRows_WADAdeer;

mysql_select_db($database_myDomain, $myDomain);
$query_WADAdeer = "SELECT DClass, DMethod, DScore, DPoints, DCountyOfKill, DYearOfKill, DHunterFirst, DHunterMiddle, DHunterLast, DMeasurerFirst, DMeasurerLast, PhotoIDfromGal, DeerID FROM deer ORDER BY DScore DESC";
setQueryBuilderSource($query_WADAdeer,$WADbSearch1,false);
$query_limit_WADAdeer = sprintf("%s LIMIT %d, %d", $query_WADAdeer, $startRow_WADAdeer, $maxRows_WADAdeer);
$WADAdeer = mysql_query($query_limit_WADAdeer, $myDomain) or die(mysql_error());
$row_WADAdeer = mysql_fetch_assoc($WADAdeer);

if (isset($_GET['totalRows_WADAdeer'])) {
$totalRows_WADAdeer = $_GET['totalRows_WADAdeer'];
} else {
$all_WADAdeer = mysql_query($query_WADAdeer);
$totalRows_WADAdeer = mysql_num_rows($all_WADAdeer);
}
$totalPages_WADAdeer = ceil($totalRows_WADAdeer/$maxRows_WADAdeer)-1;

mysql_select_db($database_myDomain, $myDomain);
$query_rsCounty = "SELECT DISTINCT DCountyOfKill FROM deer ORDER BY DCountyOfKill ASC";
$rsCounty = mysql_query($query_rsCounty, $myDomain) or die(mysql_error());
$row_rsCounty = mysql_fetch_assoc($rsCounty);
$totalRows_rsCounty = mysql_num_rows($rsCounty);

mysql_select_db($database_myDomain, $myDomain);
$query_rsYear = "SELECT DISTINCT DYearOfKill FROM deer ORDER BY DYearOfKill ASC";
$rsYear = mysql_query($query_rsYear, $myDomain) or die(mysql_error());
$row_rsYear = mysql_fetch_assoc($rsYear);
$totalRows_rsYear = mysql_num_rows($rsYear);
?>

Sign in to reply to this post

anonymous

You have a few errors in your code:

$maxRows_WADAdeer = 25;
if ($_SESSION['id']) {
$maxRows_WADAdeer> = 25;

} else {

$maxRows_WADAdeerLimit> = 5;

}

You have some extra closing carrots after $maxRows_WADAdeer (the 2nd time down)... you also have a closing carrot after the third one down. Also, you have the variable defined differently... for the first one you have $maxRows_WADAdeer and then later down in the if statement, you have $maxRows_WADAdeerLimit... those will need to be the same and you will need to get rid of the carrot(greater than) sign after the variables.

Let me know if you still have any issues,

Brian

Sign in to reply to this post

info271221

another error

Revised code:
<?php
if ($_SESSION['id']) {
$maxRows_WADAdeer = 25;

else {

$maxRows_WADAdeer = 5;

$pageNum_WADAdeer = 0;
if (isset($_GET['pageNum_WADAdeer'])) {
$pageNum_WADAdeer = $_GET['pageNum_WADAdeer'];
}

New error message:
PHP Parse error: syntax error, unexpected T_ELSE in D:\Websites\www.myDomain\RecordWhiteTail\whitetaildeer_Results2.php on line 133

Thanks,

Sign in to reply to this post

Jason ByrnesWebAssist

Please compress the original PHP page into a zip file and attach it to your reply so I can see the code at line 133 that is causing the error.

Sign in to reply to this post

info271221

files attached 2 is with new code, the other is the original

files attached 2 is with new code, the other is the original

Thanks!

Sign in to reply to this post
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...