Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Help this newbie... basic & specific question about php template for searching SQL DB
Old 05-06-2005, 07:38 AM Help this newbie... basic & specific question about php template for searching SQL DB
Junior Talker

Posts: 4
Trades: 0
You'll have to forgive me. I'm not a programmer by any stretch of the imagination, but have picked up enough basic know-how to webmaster my small business's website. Long story short, I own a karaoke company, and for about a year have wanted to put my karaoke catalog on my website in a searchable format. One of my competitors has this on his website, so I know it can be done, and probably very easily. I've managed to publish my catalog in my website's SQL database, and have looked and looked for a basic php template I could tweak (without knowing anything about coding php) in order to allow my visitors to search my catalog.

Here are the specifics:
SQL database name-- liquidkourage_net
Table name-- Karaokemusic
5 fields-- Title, Artist, Genre, Disc#, Track#

What I'm looking for...
A convenient way for visitors to fill out separate search forms for Title and/or Artist, a drop-down menu listing the different Genres (only one of those three fields would be required in the search), and a result page that lists all relevant "hits" in a small table which includes all 5 fields.

If there's a template that's completely idiotproof out there, I haven't found it yet. ANY help from the seasoned pros would be greatly appreciated.
LiquidKourage is offline
Reply With Quote
View Public Profile Visit LiquidKourage's homepage!
 
 
Register now for full access!
Old 05-06-2005, 10:02 AM
amw_drizz's Avatar
Ultra Talker

Posts: 340
Name: Jon
Location: New York
Trades: 0
have you tried creating the pages your self??? just to see if you can do it?


if you find something you like dl it and we can help you to get it operational. Most php templates are not idiot proof. they require some code editing
__________________
AMW_Drizz
Dev Machine:: Apache 2.2.6 PHP 5.2.6 MySQL 5.1
amw_drizz is offline
Reply With Quote
View Public Profile Visit amw_drizz's homepage!
 
Old 05-06-2005, 01:48 PM
leavethisplace's Avatar
Ultra Talker

Posts: 297
Trades: 0
You're probably not going to find something that specific.

If you're prepared to pay a very small amount to have it done, I'll be happy to discuss it with you?
__________________
A lie gets halfway around the world before the truth has a chance to get its pants on. - Sir Winston Churchill

Please visit my sites:
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
leavethisplace is offline
Reply With Quote
View Public Profile
 
Old 05-06-2005, 03:09 PM
hiptobesquare's Avatar
Extreme Talker

Posts: 186
Location: London UK
Trades: 0
approximately 198,764,476 vietnamese dongs should do it, thats about the going rate?
hiptobesquare is offline
Reply With Quote
View Public Profile
 
Old 05-07-2005, 02:23 AM
Junior Talker

Posts: 4
Trades: 0
Well, the good news is that after about a day of looking at tutorials and bits of script, I think I can build the "search form" page without too much difficulty-- but I have tried a few different types of code for actually processing the inputs, and I run into problems. Some of them I figured out are simply syntax errors, easily corrected, but one that keeps coming up is:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource

Does that mean I have to define that function in the code, or am I possibly messing up some syntax that I don't know about?

Also, I'm not sure if this is the crux of that problem, but I know that I need to define host, username, and password for mySQL... I know the username and password, but I'm honestly not sure what I should be putting for the host. If my script is on the same server as my DB, can I just put something along the lines of "host" or "localhost", or is there a specific host name I need to be inputting? If so, I don't what exactly my host name would be...
LiquidKourage is offline
Reply With Quote
View Public Profile Visit LiquidKourage's homepage!
 
Old 05-07-2005, 03:22 AM
Junior Talker

Posts: 4
Trades: 0
Y'all are going to laugh at me... turns out the issue was a capitalization error in the table name!

So far, I have a basic search form page that will actually return matching results in a table-like format (all html formatting)...

Now, I'd like to make it a little "prettier"...

Issues I'd like to fix--

1. As it stands right now, my searches will only return rows that start with the search string I input, e.g. I enter "Black" into the title section and will return every song I have that starts with "Black", but isn't exclusive to only the word "Black", or won't return songs where "Black" isn't the first part of the title, like "Back in Black"...

2. My results appear relative to their position in my table, e.g. they are not necessarily in any alphabetical order. I would love to have a results table that either automatically sorts results alphabetically by artist, then title, or a results table that is alphabetizable on the client side, like a spreadsheet.

Simple enough for anyone who can code html/php, but again, I only know what I have seen, which is very little.

I'll keep working at it, but any ideas would help greatly. Thanks in advance.
LiquidKourage is offline
Reply With Quote
View Public Profile Visit LiquidKourage's homepage!
 
Old 05-07-2005, 04:02 AM
leavethisplace's Avatar
Ultra Talker

Posts: 297
Trades: 0
cool LiquidKourage, good to see you managed to get this far! What you actually want to do can be done without PHP, that is it'll be done with the SQL query.

It take it you're using something like:

Code:
SELECT * FROM karaokemusic WHERE Title LIKE '%black%' ORDER BY Title ASC
Simply, for the latter part of your question, ORDER BY will sort the result set before actually returning anything back to you, you can change what is after ORDER BY and how it is ordered, ASC or DESC. You can also set more than one order clause, for example, you may want all the artists together, so you'd do ORDER BY Artist ASC, Title ASC

You'll notice around the work 'black' are some percentage signs. SQL uses these as wild-cards. Placing these at either end will find 'back in black', 'black november', 'bigblacknothingness'. So basically, anything with black in it! You can change where the wildcard goes depending on what you want to look for.

Hope that helps!
__________________
A lie gets halfway around the world before the truth has a chance to get its pants on. - Sir Winston Churchill

Please visit my sites:
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
leavethisplace is offline
Reply With Quote
View Public Profile
 
Old 05-07-2005, 04:23 AM
Junior Talker

Posts: 4
Trades: 0
Thanks a million for the advice! I was racking my brain for over an hour trying to figure out the syntax for the "CONTAINS" operator instead of using "LIKE"... figured it was going to do what i needed, jurns out i just needed to add wildcards to the front of my variable names! I'm sure I would've seen that a mile away if i were thinking clearly about the whole thing...

leavethisplace, if you're ever in my area and need a DJ, there's no charge :-)
LiquidKourage is offline
Reply With Quote
View Public Profile Visit LiquidKourage's homepage!
 
Old 05-07-2005, 04:30 AM
leavethisplace's Avatar
Ultra Talker

Posts: 297
Trades: 0
heh, unless you can do d'n'b very well I won't need a DJ
__________________
A lie gets halfway around the world before the truth has a chance to get its pants on. - Sir Winston Churchill

Please visit my sites:
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
leavethisplace is offline
Reply With Quote
View Public Profile
 
Old 05-07-2005, 07:26 AM
Republikin's Avatar
Defies a Status

Posts: 3,189
Trades: 3
Liquid, now that your all caught up with php and mysql I would like to propose a different search strategy that will only affect your sql. MySQL, since version 4.1, offers full text searching which will provide much more relevant and usefull results than using a LIKE clause.

Building upon the same query that leavethisplace put together a full text search would look like this....

Code:
SELECT * MATCH(Title) AGAINST('black') FROM karaokemusic
Now in order for this to work you would need to make a fulltext index.

Code:
CREATE FULLTEXT INDEX index_name ON karaokemusic (col1,col2,col3)
I think that's the syntax although I cant remember correctly. It's much easier to do with phpmyadmin.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Republikin is offline
Reply With Quote
View Public Profile
 
Old 05-07-2005, 08:20 AM
leavethisplace's Avatar
Ultra Talker

Posts: 297
Trades: 0
That's pretty cool, i'll have to put that to the test!
__________________
A lie gets halfway around the world before the truth has a chance to get its pants on. - Sir Winston Churchill

Please visit my sites:
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
leavethisplace is offline
Reply With Quote
View Public Profile
 
Old 05-07-2005, 08:43 AM
Republikin's Avatar
Defies a Status

Posts: 3,189
Trades: 3
I should have mentioned above that there are limits to full text searching, namely there has to be at least three rows in the table your going to search and each search term has to be more than 3 letters. Also, full text searching automatically excludes stop words like and, the, or, etc.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Republikin is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Help this newbie... basic & specific question about php template for searching SQL DB
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.85359 seconds with 12 queries