Jump to content

PHP & MySQL Code Help


Jimi_l

Recommended Posts

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

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.