Skip to main content
Participant
October 16, 2008
Question

how to display database items

  • October 16, 2008
  • 12 replies
  • 1267 views
can anyone tell me how to display the selected contents of the database by using a variable from my form field(like text box )
This topic has been closed for replies.

12 replies

Inspiring
November 13, 2008
joedt wrote:
> In this form there is a field named Client where the user can
> type in his client name. Once he hit the button, it should go to the results
> page showing all records in the "client" table that contains his client name
> (as typed in).

The user should not type in the client name after logging in. This is
insecure, because it would give the client the opportunity to see other
people's records by typing in someone else's name.

When the client logs in, you need to capture the value of client from
the login table. You can do this by using the option to restrict access
based on username, password, and access level in the Log In User server
behavior dialog box. Set "Get level from" to "client". The value of
"client" will then be stored in $_SESSION['MM_UserGroup'].

Once the client has logged in, query the loans table by using the
Recordset dialog box in Simple mode. Set the filter to match the client
column, and select Session Variable. Enter MM_UserGroup in the field
alongside Session Variable. That should bring up only loans connected
with that particular client.

--
David Powers, Adobe Community Expert
Author, "The Essential Guide to Dreamweaver CS3" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
Known Participant
November 13, 2008
Anybody, please help. I am not very familiar with PHP and MySQL so please be bear with me.
I am using Dreamweaver 8 and I have already created a login page and it works well. In my Mysql database I have 2 tables namely "login" and "loans". The "login" table I use only for login purposes and it has 3 fields namely username, password, ID and client. In the "loans" table I also have 4 fields namely "accountnr, name, client and comment. The "client" field in both tables contains the same value so that it can be linked to each other.
My problem now is: a Client logs in with his username and password (based on the login table) which takes him to his profile page showing he is logged in. I have no problem in getting this right (I have learned a lot on this forum ha ha). Now, On the profile page I have added a form to search the loans" table" for all records containing the specific client name corresponding with the specific user. In this form there is a field named Client where the user can type in his client name. Once he hit the button, it should go to the results page showing all records in the "client" table that contains his client name (as typed in). I have done exactly as advised above by David and AnotherNonCoder and the results page does in deed show records, but it shows ALL records in the "loans" table and not just those related to the specific client. Damn this is hard to explain.
If any of you intelligent people out there can understand what I am trying to do here, please help and tell me how I should go about in getting this right.
Inspiring
November 7, 2008
joedt wrote:
> if (isset(Request("State"))){
> $varState_rsStores= (get_magic_quotes_gpc()) ? Request("State") :
> addslashes(Request("State"));
> }
> $varState_rsStores = "0";
> if (isset(Request("State"))) {
> $varState_rsStores = (get_magic_quotes_gpc()) ? Request("State") :
> addslashes(Request("State"));
> }
>
> Can you find anything wrong here?

I haven't read the whole thread, but this is a nonsensical mix of ASP
and PHP. It won't work in a million years. If you're trying to write it
in PHP, it should look like this:

if (isset($_GET["State"])){
$varState_rsStores= (get_magic_quotes_gpc()) ? $_GET["State"] :
addslashes($_GET["State"]);
}
$varState_rsStores = "0";
if (isset($_GET["State"])) {
$varState_rsStores = (get_magic_quotes_gpc()) ? $_GET["State"] :
addslashes($_GET["State"]);
}

--
David Powers, Adobe Community Expert
Author, "The Essential Guide to Dreamweaver CS3" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
Known Participant
November 12, 2008
Thanks for the help everybody. It seems to work now. However, I still have the problem that it shows ALL the records in the table and not just those of the specific "State". What am I doing wrong here?
Known Participant
November 7, 2008
AnotherNonCoder, thanx. I have done everything you said but still gets an error . The error appears to be in this code :

if (isset(Request("State"))){
$varState_rsStores= (get_magic_quotes_gpc()) ? Request("State") : addslashes(Request("State"));
}
$varState_rsStores = "0";
if (isset(Request("State"))) {
$varState_rsStores = (get_magic_quotes_gpc()) ? Request("State") : addslashes(Request("State"));
}

Can you find anything wrong here?
November 2, 2008
joedt,

I tried to respond to this yesterday, but the server timed out and I had to leave. Are you still having this problem?
November 2, 2008
quote:


I tried to respond to this yesterday, but the server timed out and I had to leave. Are you still having this problem?


Well, I think I am having that same problem. Since you seem to be knowledgeable about the matter, would you mind helping others?

I am able to access my database in DW CS3 (ASP), and am able to display a datagrid with all data. What I am trying to do is allow the user drill down into the data to filter the view. I would like them to select state, then city, then see a list of stores.

I have messed around with the SQL statements so, when I run my 'Test' in my DataSet (inside of DW), I can plug the variable for "TX" in, and it spits out all Texas cities. Great! Im just not sure how to request or bind that data realtime, to where the data updates based on user selection. I have tried form and Asp variables, but cannot seem to get the variables to talk/link to the datagrid display. Yes, Im fairly new to this.

Thanks for any help.

Known Participant
October 31, 2008
AnotherNonCoder at last, it works 100%. That brings me to my next problem. And believe me, before I typed this question, I have tried to solve it by myself.
I am now trying to extract some other data from a database table, but obviously I would need another variable to display the correct record I need. With my previous problem, Dreamweaver was kind enough to create this "value" for me. All I had to do was to create a session variable called MM_Username. My question is, how do I create my own "value". Hell I dont know how to explain this. Maybe you will understand what I mean. It is easy to create a variable from the bindings panel, but obviously that is not enough to make it work. I would typicaly want to use this when creating a search form or page. The user must be able to enter any name in the database, click search button and be directed to a page displaying all records containing that name. Creating the pages is fine, but to filter is my problem.
I hope that you can understand what I am trying to say. If not, let me know so that I can try again.
Known Participant
November 6, 2008
ANYONE - HELP PLEASE!
Known Participant
October 29, 2008
AnotherNonCoder, please help again. I have done exactly as you have explained and then it worked. I dont know what I did but suddenly it wont work (see my post above). I get the idea that Dreamweaver is not making a session variable named MM_Username when i create a login form. Do you know of any reasons why? Is the viriable stored in any file so that i can go and have a look if it is there? Dont laugh please, I am not very clever at this
October 30, 2008
Hey Joe,

Sorry not been back in a while. Since the session variable is not file really but a 'value' based on the login information you will not see it in your file tree. You should however be able to see it in your Database Bindings Panel. Your problem might be that you are testing your page without being logged in, which would cause it to error. Session variables by default expire in around 20 minutes. On the page that you are displaying the recordset information on (not the login page) try this:

Click the '+' on your server behavours go to 'Restrict Access To Page', then click on 'User Authentification'. When the window opens up, click on the radio button that says 'Restrict based on username and password'. At the bottom where it says 'If Access denied ......" Click the browse button to link it to your login page. Save your file and "put" it back on the server.

What Happens Is This:

Since your member page is now based on a 'specific user' because of the filter in the recordset, if the user is not logged in, or the server times out (because maybe you were working on the page for more than 20mins/your timeout time) you get an error. (Probably - record not found)

By implementing my instructions your page will now check to see if a person is logged in 'before' it displays anything. If there is nobody logged the behavour you applied will send you back to the login page to log in so it knows what to display.

Hope this helps.....

No laughing here man, I learn just like you are... with lots of help

October 23, 2008
When you use the login feature in Dreamweaver, Dreamweaver makes a session variable named MM_Username. In your bindings panel click the + button and then choose session variable. When the little window opens up type in there MM_Username and hit ok.

Now.... on your page that displays your information create a query 'simple' that gets all the fields from the user table. You will see an option to add a filter. Choose the Session Variable option and next to it type MM_Username, and select the field in your table that stores the username.

Now when a person logs in, he/she sees his/her information.
Known Participant
October 24, 2008
IT WORKS!!! Thanx AnotherNonCoder. You're a genius
Inspiring
October 23, 2008
joedt wrote:
> I have the same problem as jessyarai. Dooza, your advice is cool, but can you
> please explain to me how to submit a variable via a form. My problem is that i
> have a php login page. after the user enters his login detail, the page should
> take him to his profile page and display this specific user's login details
> (e.g name, email address). However, it always shows the detail of the user
> that appears first in the database and not that of the logged in user

Its slightly different for you, but when your login script finds the
user and the password matches, it should set a session variable with the
user name. You then use this session variable in your recordset as the
filter.

I am not sure what its called in PHP, as I just do ASP, but I am pretty
sure its easy to find... a quick Google tells me its called MM_Username,
so in your recordset that displays the users profile, filter is on the
session called MM_Username.

Dooza

--
Posting Guidelines
http://www.adobe.com/support/forums/guidelines.html
How To Ask Smart Questions
http://www.catb.org/esr/faqs/smart-questions.html
Known Participant
October 23, 2008
Thanx. Will try.
Known Participant
October 23, 2008
I have the same problem as jessyarai. Dooza, your advice is cool, but can you please explain to me how to submit a variable via a form. My problem is that i have a php login page. after the user enters his login detail, the page should take him to his profile page and display this specific user's login details (e.g name, email address). However, it always shows the detail of the user that appears first in the database and not that of the logged in user