Problem with comparing user input to result of a query php
Whats good
I am working on a php program that reads in user input from 2 drop down menus and a text field. What I am trying to accomplish is have the user input the data from drop downs and the text field which may or may not correspond to a record in the database. The program is supposed to check if there is a record in the database that corresponds to the details entered in by the user and then refreshes the page and says whether or not it exists. After that it outputs onto a new line the same exact menu allowing you to change the details of the records the user is searching through. So basically all the info the user queried before remains on the page and he is allowed to compare it to the new info and it keeps going like that. Anyway I got drop down menus and the respawning(new menu lines) parts to work. My problem concerns the input for the text field. The user has to type in a number for the text field then that number is put into a variable. The variable is then put in as part of a query to the db. What I dont understand how to do is compare the input text to the result of the query. To reiterate I am trying to check if a number the user enters exists in the database. I am looking for any suggestions on how to do this. Here is the part of the code I am working with. The whole program is too long to post. I am working with an oracle database and I only have access to it through the php. Thanks for reading through all of this. Code:
echo("<td>"); |
Quote:
Code:
SELECT count(*) FROM table WHERE number = number_entered |
I dont understand if this statement returns the number of times the input appears or actually returns where the input appears.
For example if the user types in "42" and "42" appears twice does the statement return the number 2 signifying that it appears twice or does it return 2 rows where the "42" is located? If it returns the latter how would I compare it code wise? I am using severel functions to work with the database oci_parse and ociexecute. These also return 1 if true or 0 if false from what I understand about them. I think I should compare the user input to the actual row of the db where the number is located but I dont know how to do this. Another way Im thinking of taking this is saying if the ociexecute returns true then the number exists. But I think this may be flawed if ociexecute returns true even if the number doesnt exist in the database. The PHP manual says this about ociexecute "Returns TRUE on success or FALSE on failure." Does that mean failure to connect to the db or failure to find anything in the db? Any suggestions would be appreciated. Heres a piece of code Code:
//to create the text field. |
count returns the number of occurrences, so you can see if it exists on the database and then proceed.
|
All times are GMT -5. The time now is 02:51 PM. |