Jimi_l Posted October 24, 2007 Share Posted October 24, 2007 Hi All, I have two questions in regards to PHP and MySQL that I hope someone will help me with with. I understand if this seems to "write it for me" but I have looked all over the place for a few days with no luck. Anyway, any help or direction is appreciated. If this single data entry form- <form name="form" action="search.php" method="get"> <input type="text" name="q" /> <input type="submit" name="Submit" value="Search" /> </form> Calls to this function to search- $var = @$_GET['q'] ; $trimmed = trim($var); //trim whitespace from the stored variable How would a form with three user supplied entires change to include all three variables? In other words search for "q" and "r" and "s"? Second question. If this code calls to search a given table and field for that single search field- $query = "select * from the_table where 1st_field like \"%$trimmed%\" order by 1st_field"; How could it be rewritten to search ALL tables and fields of a single DB using all three user supplied fields? The DB has about 30 tables and many fields in each which I would assume would require a zillion "and's" but I suspect there is a better way. Thanks in advance for any help, Jim Quote Link to comment https://forums.phpfreaks.com/topic/74578-php-mysql-code-help/ Share on other sites More sharing options...
fenway Posted October 24, 2007 Share Posted October 24, 2007 There's no way to query across an entire DB with a single query -- you'd have to look into 3rd party indexing solutions. Quote Link to comment https://forums.phpfreaks.com/topic/74578-php-mysql-code-help/#findComment-377024 Share on other sites More sharing options...
Jimi_l Posted October 24, 2007 Author Share Posted October 24, 2007 Really? That seems a little counter intuitive for a database. Do you have any pointers as to a third party indexing application? Actually I am greatly amazed how difficult this project has turned out. You would think that searching an entire DB would be easily accomplished with any number of editable pre-existing open source script, but it's not. Even a single variable for a single table and field is a chore. Heck I can't even find commercial software that does it. Crazy stuff. Jim Quote Link to comment https://forums.phpfreaks.com/topic/74578-php-mysql-code-help/#findComment-377396 Share on other sites More sharing options...
Jimi_l Posted October 25, 2007 Author Share Posted October 25, 2007 Me Again, I noticed that the phpmyadmin interface allows you to search all tables and fields but does not show the code on how it is being accomplished. If you search one table, all fields it displays the search code in a little window but not for an all/all query. Any ideas on this? Thanks again, Jim Quote Link to comment https://forums.phpfreaks.com/topic/74578-php-mysql-code-help/#findComment-377665 Share on other sites More sharing options...
fenway Posted October 25, 2007 Share Posted October 25, 2007 Me Again, I noticed that the phpmyadmin interface allows you to search all tables and fields but does not show the code on how it is being accomplished. If you search one table, all fields it displays the search code in a little window but not for an all/all query. Any ideas on this? Thanks again, Jim Sorry, you said DB and it sounds like you mean table.... you can full-text index across up to 16 columns, or use LIKE to match as many as you want... it's just slow. Quote Link to comment https://forums.phpfreaks.com/topic/74578-php-mysql-code-help/#findComment-378014 Share on other sites More sharing options...
Jimi_l Posted October 25, 2007 Author Share Posted October 25, 2007 Hi Fenway, I did mean entire database. I can select all 23 tables and it will search every field of every table in that one databse almost instantly. Jim Quote Link to comment https://forums.phpfreaks.com/topic/74578-php-mysql-code-help/#findComment-378260 Share on other sites More sharing options...
fenway Posted October 26, 2007 Share Posted October 26, 2007 Hi Fenway, I did mean entire database. I can select all 23 tables and it will search every field of every table in that one databse almost instantly. Jim Then it must be running the LIKE query for every table... easy to automatically generate that from the schema... but "instantly" probably has to do with the amount of info in the DB. I've never heard or seen this feature. Quote Link to comment https://forums.phpfreaks.com/topic/74578-php-mysql-code-help/#findComment-378603 Share on other sites More sharing options...
Jimi_l Posted October 27, 2007 Author Share Posted October 27, 2007 Hi, The DB itself is not that large but phpmyadmin does shot out a butload of code for even a simple search. It has the feature to "show php" in regards to what it is doing for the query and even a single table is about a page long so all of them must be 23 times that at least. I think my issue (at least one of them anyway) is a crappy DB to begin with. I was handed this as is so I may start from scratch but even then it would just be a zillion fields as opposed to tables. I appreciate the input, Jim Quote Link to comment https://forums.phpfreaks.com/topic/74578-php-mysql-code-help/#findComment-379106 Share on other sites More sharing options...
fenway Posted October 27, 2007 Share Posted October 27, 2007 That's because there is no "search", as I said before. Quote Link to comment https://forums.phpfreaks.com/topic/74578-php-mysql-code-help/#findComment-379525 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.