Jump to content

possible with php and mySQL?!?!?


son.of.the.morning

Recommended Posts

Is it possible for php the check for individual letters in a sql record. For example is the word 'superman' was stored in sql record and my page told the user to input the first, fourth and last letter of the word into a text box would php be able to check the record to see if the letter exists the word and that they are in the correct order?

Link to comment
https://forums.phpfreaks.com/topic/213501-possible-with-php-and-mysql/
Share on other sites

Since this word in stored in a database, you would generally want to do this in a query and check if the query matched any row(s) -

 

$first, $fourth, and $last php variables hold the entered characters. The underscore _ wildcard character ignores the 2nd, 3rd, 5th, 6th, and 7th positions -

 

$query = "SELECT COUNT(*) FROM your_table WHERE your_column LIKE '$first__$fourth___$last' AND another_condition_that_identifies_the_specific_word_you_want_to_check"

i want to write a code, which will ask for different letters every time and once the user has submitted the form with the text box in it will then check to see if the letters are correct and in the right order from what the first page had indicated to the user.

 

 

I have just read a short tutorial on wildcard in php, i cant access my ftp at the moe so i cant try the code.

 

Dont no if this will work, does this seem right?

$word = superman
$match = $word[1].$word[2].$word[5];
if ($pWord == $match) {
echo "ya mar";
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.