iEntry 10th Anniversary Forum Rules Search
WebProWorld
Register FAQ Calendar Mark Forums Read
Database Discussion Forum This is the place to find help resolving those nagging questions you have about implementing and using all kinds of databases. Need help writing a query? Need an opinion on Oracle? Post here!

Share Thread: & Tags

Share Thread:

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 09-16-2004, 05:51 PM
WebProWorld New Member
 
Join Date: May 2004
Location: Kent, UK
Posts: 17
Stooge RepRank 0
Default Search/results problem, please help!

Hi there,

I have a database with lots of names, and i'm having immense trouble trying to get a search page to query the database and send back the results.
I'm doing it all in Dreamweaver using PHP and the database is MySQL. I can display the database on a php page no problem, and make a form that inputs new names, but I can't for the life of me set up a search page, and have the searched name displayed from the db. All I keep getting is the whole db displayed instead of just the info I want.
Does anybody know of a good step by step tutorial to help me, or any advice to put me straight would be excellent and very much appreciated.

Thanks in advance!
__________________
CVA Design
Freelance Web Designer Kent UK
Reply With Quote
  #2 (permalink)  
Old 09-16-2004, 06:59 PM
WebProWorld Pro
 
Join Date: Aug 2004
Location: UK
Posts: 124
SteveF RepRank 0
Default

What is the query that runs to search for the name?
__________________
SteveF
Projectors
Reply With Quote
  #3 (permalink)  
Old 09-16-2004, 08:16 PM
WebProWorld New Member
 
Join Date: May 2004
Location: Kent, UK
Posts: 17
Stooge RepRank 0
Default

SELECT FIRSTNAME, LASTNAME, YEAR STARTED, ETC FROM DBNAME WHERE LASTNAME LIKE 'varLastName' AND YEARSTARTED LIKE 'varYearStarted'

Thanks SteveF, i'm not at work so i've had to do this from memory, but the general jist of the search form is to aquire all database details about the person by submitting either last name and/or year started.

Cheers!
__________________
CVA Design
Freelance Web Designer Kent UK
Reply With Quote
  #4 (permalink)  
Old 09-17-2004, 05:41 AM
WebProWorld Pro
 
Join Date: Aug 2004
Location: UK
Posts: 124
SteveF RepRank 0
Default

The query needs looking at,
dont like the 'like'
if you want to find one record use =
and you need a Or not an "and"

But your first query should have not retrieved all the records each time, so make sure your form is loading the correct query - put a write statement to output your query to screen to check what is the current statement
__________________
SteveF
Projectors
Reply With Quote
  #5 (permalink)  
Old 09-17-2004, 07:34 AM
WebProWorld New Member
 
Join Date: May 2004
Location: Kent, UK
Posts: 17
Stooge RepRank 0
Default

Not sure how to output the statement to screen....but the error message I get when i attempt to use the search form now is:

Parse error: parse error, unexpected T_STRING, expecting T_VARIABLE or '$' in d:\web\results.php on line 6

This is the sql used:
SELECT FIRST_NAME, LAST_NAME, YEAR_STARTED, NETWORK_ACCESS, INTERNET_ACCESS, IMAGES
FROM test2
WHERE LAST_NAME LIKE 'varLastName' AND YEAR_STARTED LIKE 'varYearStarted'

Yesterday the whole database appeared, now all i get is the above error.
I changed AND to OR and the query brings back no results (within the Variables box 'test' button) so it seems to like the AND syntax.

I have had success with entering a letter in the Default Value and it brings back all sirnames starting with that letter, but if i enter a name that IS in the db it comes back saying 'no records'.

I hope this makes sense, if i can provide any more info just let me know.

Thanks!
__________________
CVA Design
Freelance Web Designer Kent UK
Reply With Quote
  #6 (permalink)  
Old 09-17-2004, 08:14 AM
WebProWorld Pro
 
Join Date: Aug 2004
Location: UK
Posts: 124
SteveF RepRank 0
Default

Is your yearstarted a text field or a number

If its a number you will have to change the query expression as its looing at a text field.

Still dont like the and
are you inputing both search items when searching or just one,
__________________
SteveF
Projectors
Reply With Quote
  #7 (permalink)  
Old 09-17-2004, 08:34 AM
WebProWorld New Member
 
Join Date: May 2004
Location: Kent, UK
Posts: 17
Stooge RepRank 0
Default

yearstarted is a number, in the form as a drop down menu with the year variables ie 2001, 2002 etc.

The idea is to input name and/or date into the form. I have been testing by inputting one and both but I still get the same sparse error
__________________
CVA Design
Freelance Web Designer Kent UK
Reply With Quote
  #8 (permalink)  
Old 09-17-2004, 09:03 AM
WebProWorld New Member
 
Join Date: May 2004
Location: Kent, UK
Posts: 17
Stooge RepRank 0
Default

I just managed to get rid of the parse error by including a $ in the sql syntax on line 6.

The results page is now always displaying the first name in the db, but i can't get the results to display anything different. Any ideas?
__________________
CVA Design
Freelance Web Designer Kent UK
Reply With Quote
  #9 (permalink)  
Old 09-17-2004, 09:19 AM
WebProWorld Pro
 
Join Date: Aug 2004
Location: UK
Posts: 124
SteveF RepRank 0
Default

Make sure your form is loading the correct query - put a write statement to output your query to screen to check what is the current statement
(taking son back to Uni now will be back much later)
__________________
SteveF
Projectors
Reply With Quote
  #10 (permalink)  
Old 09-21-2004, 12:06 PM
WebProWorld New Member
 
Join Date: Apr 2004
Location: Vancouver
Posts: 1
RonCSchultz RepRank 0
Default Search/results problem, please help!

Hi Stooge
Just a thought.
It looks like you are trying to use the advanced search screen with a dynamic variable that is set at run time.

I have been working with mysql and dreamweaver for about 6 months now. I'm trying to learn how to make all the parts work together. I also had difficulty using that screen to set a variable at run time.

The general problem that I had was that dreamweaver generated code that I didn't understand. I took a few steps back, bought a few books on php and mysql and learned how to generate the main database componenets by hand. I now can write code to add, edit, search and modify the db. As a result I now have a better understanding of how dreamweaver code works.

I would suggest that you try to get your mysql select statements to work from the command line. Once you have done that then write code manually to search the database and print it to the screen. After you do that you may have a better understanding of how to use dreamweaver to do it.

If you are interested I can send you basic php code to do simple search.

A different alternative would be to find a dreamweaver guru to tell you how to set up a search var using the advanced dreamweaver search screen.

Ron
Reply With Quote
Reply

  WebProWorld > Webmaster, IT and Security Discussion > Database Discussion Forum

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 10:32 PM.



Search Engine Optimization by vBSEO 3.3.0