FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


CREATE INDEX





Shike
Can I use phpmyadmin to Create an Index of an existing table, or do I need to do it through PHP?
Ratman2050
Isnt PHP the same thing as PHPMYADMIN. And yes you can do it through PhpMyAdmin. But first you need to create a data table file. I noticed you said you already have one. So go to PhpMyAdmin. Click on your database.

Then click on Where it says Tables, instead of inserting your own save one on the desktop go to browse find your data table. Upload. Then run query

It should then show all of your tables
Marston
Ratman2050 wrote:
Isnt PHP the same thing as PHPMYADMIN.
I would disregard this entire post.
Rhysige
What exactly do you mean?
Philip
Shike wrote:
Can I use phpmyadmin to Create an Index of an existing table, or do I need to do it through PHP?


it;'s the same way, phpmyadmin also using php through for creatin index. Smile
but i suggest it for always using php my admin since it have a better gui. Smile


DanielXP
I have done this a few time not having an index as the id or what ever.

u could just delete it and then run the SQL again with auto_increment on the one you want the index to be.
Marston
Rhysige wrote:
What exactly do you mean?
Because: PHP is a scripting language. PHPMyAdmin is a program written in PHP used to interface with databases. Obviously the person who said that is severly misinformed.
snowboardalliance
Ratman2050 wrote:
Isnt PHP the same thing as PHPMYADMIN. And yes you can do it through PhpMyAdmin. But first you need to create a data table file. I noticed you said you already have one. So go to PhpMyAdmin. Click on your database.

Then click on Where it says Tables, instead of inserting your own save one on the desktop go to browse find your data table. Upload. Then run query

It should then show all of your tables


Well sort of, phpmyadmin is just a php page that gives a simple GUI for mysql, so you can use that.
Shike
Ok, I have a couple of questions regarding the Index feature of MySQL. First, I know how to create the index now. But How, through my script, do I search the index.

Somone mentioned that just listing the columns to be searched could do the trick, but I plan on having thousands of records in my database.

Next question, as the number of records grows, do the words in the index alter as well (I think I remember seeing somewhere if a word appears in 50% of records, it doesn't appear in the index).

Any help would be great.

Thanks
SlowWalkere
When you create an index, it just indexes one of the current fields in your table. When you search that field, mySQL will automatically use the index.

So, if you have a field called "Name" that you look up often and created an index of "Name," you will still just do something like...
SELECT * FROM table WHERE Name = 'x';
Using the indexed field as a WHERE parameter will automatically use the index... (at least I think that's how it works).

The 50% rule that you mentioned only applies to a special kind of index - FULLTEXT indices. A regular index will index every value in that column. It's good for searching numeric data or one word fields (First name, last name, etc). Fulltext, on the other hand, is used for indexing and searching through longer strings, where you want to find if a certain word or two appears in the bigger string (like searching through websites).

In the case of fulltext indices, yes, only words that appear in less than 50% of the data rows will be indexed. That's because you're searching through it to narrow down the possible fields, and something that appears in the majority of fields doesn't help narrow the field much. And yes, I think that every time you add a new record to the indexed table, mySQL will have to recreate the index over again (and some words may be added/dropped depending on that 50% rule).

If you're using a fulltext index, the syntax for select is somewhat different. The basic search is something like this....
SELECT * FROM txtTable WHERE MATCH (txtField) AGAINST ('searchstring');

That will return any rows where the FULLTEXT index of txtField contains the word/string 'searchstring'.

You can also do fancier searches (to look for multiple words, only require some, require that others not be present, etc). Check out the mySQL documentation or http://www.hudzilla.org/phpbook/read.php/9_3_18. That link has an overview of fulltext indexes, so if what I said doesn't make sense try reading it.

- Walkere
Shike
Ok, I guess a little more explination is needed. I want a FULLTEXT index that will Index Multiple Fields. here is my code for the search at website search page

Code:

if ( $bool1 == "AND" ){
   $search1 = "MATCH($type1) AGAINST('+$terms1[0], +$terms1[1], +$terms1[2], +$terms1[3]' IN BOOLEAN MODE)";
} elseif ( $bool1 == "OR" ){
   $search1 = "MATCH($type1) AGAINST('$terms1[0], $terms1[1], $terms1[2], $terms1[3]' IN BOOLEAN MODE)";
} elseif ( $bool1 == "phrase" ){
   $search1 = "$type1 LIKE \"%$term1%\"";
}
if ( $terms2 != "" ){
   if ($bool2 == "AND" ){
      $search2 = "$op1 (MATCH($type2) AGAINST('+$terms2[0], +$terms2[1], +$terms2[2], +$terms2[3]' IN BOOLEAN MODE))";
   } elseif ($bool2 == "OR"){
      $search2 = "$op1 (MATCH($type2) AGAINST('$terms2[0], $terms2[1], $terms2[2], $terms2[3]' IN BOOLEAN MODE))";
   } elseif ($bool2 == "phrase"){
      $search2 = "$op1 ($type2 LIKE \"%$term2%\")";
   } else {
      $search2 = "";
   }
}
if ( $terms3 != "" ){
   if ($bool3 == "AND" ){
   $search3 = "$op2 (MATCH($type3) AGAINST('+$terms3[0], +$terms3[1], +$terms3[2], +$terms3[3]' IN BOOLEAN MODE))";
   } elseif ($bool3 == "OR"){
   $search3 = "$op2 (MATCH($type3) AGAINST('$terms3[0], $terms3[1], $terms3[2], $terms3[3]' IN BOOLEAN MODE))";
   } elseif ($bool3 == "phrase") {
   $search3 = "$op2 ($type3 LIKE \"%$term3%\")";
   } else {
      $search3 = "";
   }

if ( $term3 != "" ) {
    $search = "SELECT * FROM dnd WHERE $search1 $search2 $search3 ORDER BY $sort";
} elseif ( $term2 != "") {
   $search = "SELECT * FROM dnd WHERE $search1 $search2 ORDER BY $sort";
} elseif ( $term1 != "" ){
   $search = "SELECT * FROM dnd WHERE $search1 ORDER BY $sort";
}


Within this context I want to be able to search the FULLTEXT index of Multiple Fields.
Related topics
How to create a dynamic PHP website.
How to create a favicon
.htacess in phpBB ?
how to create your own XXX gig file compressed to NNN kbytes
Index page load order
Can't Update Index.html
Index page for images, putting them all on one page 50fri$!!
40Frih for Help with .htaccess problem
Is index.html different from public_html.html
Automatic index
Uploading/Creating Files
TextBlockWriter
Help me writing this query. Urgent
Portable Dirhtml 4.854
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.