close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Creating queries

Thread began 2/18/2020 7:38 pm by balexander389215 | Last modified 3/16/2020 12:18 pm by Ray Borduin | 210 views | 20 replies |

balexander389215

Creating queries

I am creating a database for venues in the US and Canada. What I would like is to set it up that users can select a state and only receive the list for that state, sorted by city. Do I have to create 50 different pages with a query for each state on it's own page or is there a way to set it up that the user selects the state and the query is created for that state?

Also when creating the Repeat Region you choose the number of rows of data that you want to display. However I often see displays where the user can choose to see more or fewer rows. Is there a way to set this up that a user can choose to see 30 or 50 or 100 rows of data?

Thanks.

Sign in to reply to this post

Ray BorduinWebAssist

You can use a single page where the user selects the state and then add a WHERE clause to the recordset to filter based on the submitted value.

There is no way to allow the user to select the number of rows displayed from the UI, but it can easily be accomplished with hand coding.

The way to do this is to set a session variable with the default number of rows you want displayed the first time the user comes to the page (when it isn't already set). Then reset it to the number of rows chosen when they choose a new number of rows through the form submit.

Then the manual part is that you need to go into the code and replace the number of rows with the reference to the session variable that was set.

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

balexander389215

Thanks Ray, is there a tutorial that would show me how to do that?

Sign in to reply to this post

Ray BorduinWebAssist

There is no tutorial that I know of on how to do that, but I don't think it would be too hard to pull off.

Start by just getting a session variable set and controlled so that it changes values based on the user input you want to use.

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

balexander389215

Hi Ray,

I’m still looking for a way to create tables but allow users to set the number of rows displayed. I found a script designed to allow the user to do just that. I tried to make it work with the table created from the webassist aps but I'm not a programmer and could not figure it out. You on the other hand could take a look and know within a minute if you could integrate it into your work.

If it can be done please let me know the cost to make this work.

Here is a link to the site where he has a demo. https://makitweb.com/change-number-rows-show-in-the-pagination-using-php/

It is really just this section that I am looking for:

<div class="divnum_rows">
<span class="paginationtextfield">Number of rows:</span>&nbsp;
<select id="num_rows" name="num_rows">
<?php
$numrows_arr = array("5","10","25","50","100","250");
foreach($numrows_arr as $nrow){
if(isset($_POST['num_rows']) && $_POST['num_rows'] == $nrow){
echo '<option value="'.$nrow.'" selected="selected">'.$nrow.'</option>';
}else{
echo '<option value="'.$nrow.'">'.$nrow.'</option>';
}
}
?>
</select>
</div>

On another note you used to have a number of video tutorials but I believe they were in Flash. It’s not that difficult to convert from Flash to MP4. If you have a link to these old videos I would be happy to convert them for you and you could put them up on Youtube.

Brian

Sign in to reply to this post

Ray BorduinWebAssist

You should be able to use that code to create a select list to select the number of rows. However, you would still want to save the result in the session so it would be maintained when switching pages.

The code you supplied is just 1 of 3 pieces that have to work in conjunction.

1) The html that creates the select list
2) The code that saves the submitted choice into the session and sets the default value
3) The code that sets the number of rows in the recordset to use the session

Place that code you supplied onto your page where you want to use it. At that point you will have a select number of rows field that you then just have to tie into the recordset and session. Attach that page with step 1 complete, and I can comment on the code that needs to be updated for step 2.

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

balexander389215

i am still trying to figure out how to allow users to select the State to create the query. Doing a lot of research I can't find a way to include a variable from the form submit in the Recordset that would allow for a dynamic query. Perhaps it would work better if did the the query in PHP rather than a Record set. I created a simple only allowing for a state dropdown.

<div id="RichRegistration_NewFromBlank_Default_ProgressWrapper">
<form class="NewFromBlank_Default" id="RichRegistration_NewFromBlank_Default" name="RichRegistration_NewFromBlank_Default" method="post" action="">
<!--
WebAssist CSS Form Builder - Form v1
CC: Registration
CP: Rich Registration
TC: <New From Blank>
TP: Default
-->
<fieldset class="NewFromBlank_Default" id="Registration">
<legend class="groupHeader"></legend> <span class="buttonFieldGroup" >
<input class="formButton" name="RichRegistration_submit" type="submit" id="RichRegistration_submit" value="Enter" undefined title="Please enter a value">
</span>
<span class="fieldsetDescription"> </span>
<div class="lineGroup">
<label for="State" class="sublabel" > State:</label>
<select class="formMenufield_Medium" name="State" id="State" rel="<?php echo((isset($_GET["invalid"])?ValidatedField("state","State"):"")); ?>"undefined title="Please enter a value">
<option value="" <?php if (!(strcmp("", (isset($_GET["invalid"])?ValidatedField("state","State"):"")))) {echo "selected=\"selected\"";} ?>>Select a State</option>
<option value=" " <?php if (!(strcmp(" ", (isset($_GET["invalid"])?ValidatedField("state","State"):"")))) {echo "selected=\"selected\"";} ?>>N/A</option>
<option value="AL" <?php

.....

<option value="WI" <?php if (!(strcmp("WI", (isset($_GET["invalid"])?ValidatedField("state","State"):"")))) {echo "selected=\"selected\"";} ?>>Wisconsin</option>
<option value="WY" <?php if (!(strcmp("WY", (isset($_GET["invalid"])?ValidatedField("state","State"):"")))) {echo "selected=\"selected\"";} ?>>Wyoming</option>
</select>
</div>

</fieldset>
</form>
</div>
<div id="RichRegistration_NewFromBlank_Default_ProgressMessageWrapper" class="blockUIOverlay" style="display:none;">
<script type="text/javascript">
WADFP_SetProgressToForm('RichRegistration_NewFromBlank_Default', 'RichRegistration_NewFromBlank_Default_ProgressMessageWrapper', WADFP_Theme_Options['BigSpin:CaboSunset']);
</script>
<div id="RichRegistration_NewFromBlank_Default_ProgressMessage" >
<p style="margin:10px; padding:5px;" ><img src="webassist/progress_bar/images/cabo-largespin.gif" alt="" title="" style="vertical-align:middle;" />&nbsp;&nbsp;Please wait</p>
</div>


Whether it is done in PHP or the record set I have the same question, what do I put in the select statement that would allow the query to use the State selected from form submit?


$sql = "SELECT * FROM venue WHERE Country = 'USA' and state = (what do I put in here that would indicate the state selected from submit from the form?) ORDER BY City ASC limit $row,".$rowperpage;

Thanks

Sign in to reply to this post

Ray BorduinWebAssist

Call me using the number at the bottom of the screen. I'll set up a screen sharing session to show you how it is done. Once I show you a few simple concepts I think this will click and you will be able to do this on your own pretty easily.

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

balexander389215

Hi Ray, thanks for the help, things are looking good, Something I meant to check with you, on some earlier p[ages I created I did them before upgrading to Databridge 2. So the connection was <?php require_once('Connections/songwriters.php'); ?>. I have since created a new connection songwritersi. Do I have to recreate this whole page or can I simply change <?php require_once('Connections/songwriters.php'); ?> to <?php require_once('Connections/songwritersi.php'); ?> and adding <?php require_once('webassist/mysqli/rsobj.php'); ?> to the page as well.

Also two other places:

<?php
// WA DataAssist Insert
if (isset($_POST["RichRegistrationCountryCode_submit"]) || isset($_POST["RichRegistrationCountryCode_submit_x"])) // Trigger
{
$WA_connection = $songwriters; (would change songwriters to songwritersi here?)
$WA_table = "users";
$WA_sessionName = "register_id";
$WA_redirectURL = "confirm.php";
if (function_exists("rel2abs")) $WA_redirectURL = $WA_redirectURL?rel2abs($WA_redirectURL,dirname(__FILE__)):"";
$WA_keepQueryString = false;
$WA_fieldNamesStr = "Membership_type|UserFirstName|UserLastName|stagename|UserEmail|Password|UserCity|UserCountry|UserState|genre1|genre2|BIO|member_image|website|audio1|audio2|audio3|video1|video2|video3";
$WA_fieldValuesStr = "".((isset($_POST["Membership_type"]))?$_POST["Membership_type"]:"") ."" . $WA_AB_Split . "".((isset($_POST["First_Name"]))?$_POST["First_Name"]:"") ."" . $WA_AB_Split . "".((isset($_POST["Last_Name"]))?$_POST["Last_Name"]:"") ."" . $WA_AB_Split . "".((isset($_POST["AKA"]))?$_POST["AKA"]:"") ."" . $WA_AB_Split . "".((isset($_POST["Email_Address"]))?$_POST["Email_Address"]:"") ."" . $WA_AB_Split . "<".WA_SHA1Encryption(((isset($_POST["Password"]))?$_POST["Password"]:"")) ."" . $WA_AB_Split . "".((isset($_POST["City"]))?$_POST["City"]:"") ."" . $WA_AB_Split . "".((isset($_POST["Country"]))?$_POST["Country"]:"") ."" . $WA_AB_Split . "".((isset($_POST["State"]))?$_POST["State"]:"") ."" . $WA_AB_Split . "".((isset($_POST["genre1"]))?$_POST["genre1"]:"") ."" . $WA_AB_Split . "".((isset($_POST["genre2"]))?$_POST["genre2"]:"") ."" . $WA_AB_Split . "".((isset($_POST["BIO"]))?$_POST["BIO"]:"") ."" . $WA_AB_Split . "".((isset($_POST["image"]))?$_POST["image"]:"") ."" . $WA_AB_Split . "".((isset($_POST["url"]))?$_POST["url"]:"") ."" . $WA_AB_Split . "".((isset($_POST["audio1"]))?$_POST["audio1"]:"") ."" . $WA_AB_Split . "".((isset($_POST["audio2"]))?$_POST["audio2"]:"") ."" . $WA_AB_Split . "".((isset($_POST["audio3"]))?$_POST["audio3"]:"") ."" . $WA_AB_Split . "".((isset($_POST["video1"]))?$_POST["video1"]:"") ."" . $WA_AB_Split . "".((isset($_POST["video2"]))?$_POST["video2"]:"") ."" . $WA_AB_Split . "".((isset($_POST["video3"]))?$_POST["video3"]:"") ."";
$WA_columnTypesStr = "',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''";
$WA_fieldNames = explode("|", $WA_fieldNamesStr);
$WA_fieldValues = explode($WA_AB_Split, $WA_fieldValuesStr);
$WA_columns = explode("|", $WA_columnTypesStr);
$WA_connectionDB = $database_songwriters; (and here as well?

thanks Brian
mysql_select_db($WA_connectionDB, $WA_connection);
@session_start();


Thanks Brian

Sign in to reply to this post

Ray BorduinWebAssist

You have to re-apply any server behaviors that use the connection to update that code to mysqli, you cannot just update the connection without updating the other code on the page.

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...