Is there a more efficient way to do this? In order to find a row based on one of the variables in it, I've been doing this: A little reference here would be: $table - the name of my table $tvar - a variable to test in the row $var - another variable to pull from the row $vvar - the value of the variable to find // The variable to match $vvar = "digitalpoint"; // Select everything in my table. $result = mysql_query("SELECT * FROM $table"); // Start the WHILE loop until the end of the table is reached. while($row = mysql_fetch_array($result)) { // Pull the testing variable from the row. $tvar = $row['var']; // Tests to see if the testing variable in the row ($tvar) and the variable it's supposed to find ($vvar) are alike. if ($tvar == $vvar) { // Pull whatever other variables from the row. $var = $row['var2']; // This is a matching row, so do something with the other variables in the row. } } PHP: Basically what happens is that it scrolls through the entire table & looks for a row where "var" is digitalpoint. Once it finds something, it can do something with all of the variables in that row. It will repeat the process for every matching row where the "var" column is "digitalpoint". Is there a more efficient way than manually scrolling through the entire MySQL table? Like a "FIND" command or something? Or is the WHILE loop the standard way to do this? I'm just a little concerned on what would happen if a table would grow to a huge size. EDIT: I swear I've seen something before where the "FOREACH" command was used. I'm just not sure how to implement it.
lol. What's wrong with doing it normal? like this: // The variable to match $vvar = "digitalpoint"; // Select everything in my table. $result = mysql_query("SELECT * FROM $table where var = '$vvar'"); PHP: