Using Mysql/Ajax to populate Form using value from Input Fields - mysql

Am trying to populate a reasonably large form (40 odd fields) with values from a MySQL database.
I have no problems creating the JSON array from the query.
echo json_encode($row);
What I would like to achieve is difficult to find out from other posts etc and it may be impossible to do.
What I wish to do...
Use 2 Input Fields that both must be filled correctly before populating the rest of the form.
So
FIELD1 = Membership No
FIELD 2 = Drivers License No.
(A quick sort of Security Check)
So if FIELD1 AND FIELD2 equals values in the database, then populate the rest of the form.
Nothing happens UNTIL BOTH fields are filled.
My mysql query is a straight forward - WHERE FIELD1='value1' AND FIELD2='value2'
Is this at all possible to do?
The other approach I was contemplating was to somehow use AJAX to update the mysql query with the input values, then refresh the page. The query would change to EG WHERE FIELD1='56779' AND FIELD2='Q16987999'

I am not pursuing this any further. Too complicated when I can just create a "Login" style form using Member No and Drivers Licence as the Username and password, then POST these values to the SQL Query on the next page.
Then a simple SELECT query to populate all necessary fields with mysqli_fetch_assoc

Related

Use List Box with Multiple Selection in Query

Given I've created an Access Form with a ListBox; property > other > Multi Select = Extended; which permits multiple selections.
User selects multiple items.
Clicks a button that creates a report in "Print Preview"; but this report is based on the query, and the query is based on the values in the form.
This is accomplished by using this in the query when viewing in Access Query Design View (not SQL):
Like ([forms]![padc]![V2])
Where the form name is padc and the value to compare is V2.
Previously, rather than the ListBox that might show 10 options, V2 was just a field with one value. A user would either type a partial value, such as jack*, and the report would pull every instance where this value began with jack; whether that was jack, or jackie, or jacko, or jackson, etc. The LIKE part of this permitted the "fuzzy" logic bringing about varied results. The query would run, and the report would show all the records with anything starting with jack.
My goal, really, is to have a user select one, two or three, or all the available options in this box, and have the report respond correctly.
I believe the ListBox will let me do this, provided I have all the right names in the table that is the source of the options available to choose from.
I set the listbox to "multi-select" to enable multiple selections on the form.
The form is happy. It can let me click/highlight one or several items from the list.
The query is not happy.
For the field V2, neither
Like ([forms]![padc]![V2])
nor
=([forms]![padc]![V2])
Will retrieve records to populate the report; regardless of whether or not just one value in ListBox is selected or multiple values. (Like = fuzzy, and = means exact match.)
Neither work.
Of course, if the query won't perform, then the report won't perform either.
How can I write the correct query in Access, using "Query View = Design View" and or SQL to get this to function properly?
If the answer is "it can't be done without using VBA" then please point me to the VBA solution that a 5-yr old can understand, because I have zero experience using VBA.
Folks have recommended I use VBA; specifically that I should incorporate the "IN() IN function" in some manner; but I don't comprehend this solution at all.
I admit to being ignorant; not stupid; but ignorant.

mySQL - how to convert "condensed in 1 column data" to standard table with multiple columns

I have a form (using a tool called Easy Forms) that writes data from form entries into a mysql database. However, the data is stored in a strange way, the likes of csv format.
1 entry = 1 line in the table, but all the information the user submits is stored in one single column named "data", like this:
{"text_734077":"John","text_442391":"Doe","text_485406":"+4101020304","email_876265":"john.doe#email.com","textarea_508384": etc ...
I believe "text_734077" and the other similar values are the names/types of the fields in the form.
I need to use this data with another tool, but I cannot do anything with this.
I did not create this database and form, but I will be managing it in the future.
How can I transform this into a standard table with real columns (name, email, phone, ID, etc) within mysql? The Easy Forms tool can display this data as a table so I should be able to do it as well:
But this would be perfectly fine as well:
I could create a new table and insert the data manually for the 200 entries but there are new ones everyday, it needs to be automatic.
Thanks and have a great day
PS: Sorry for the bad title, I couldn't describe this problem in another way

Microsoft Access Form To Query for Multi Value Field

I am trying to write an Microsoft Access query from a form with a multi value field being the criteria. The field I am trying to use is called Population and the field is represented in my database as a List Box that allows multiple values and it is in the Building table. The values it allows are the following:
"Singles";"Familes";"Families with Children";"Youth/Young Adults";"Veterans";
The form that I am creating is called HousingSearch.
I am trying to create a form which uses this field, so someone could use the list box and check off the values they want and click on the button which would open a query. I know having done this with single value fields the criteria in the query looks something like
[forms]![HousingSearch]![Building]![Population]
but if you try the same thing for a multi value field nothing is returned for the query. Any help would be appreciated.
From the information you have provided it seems that the phrase [Forms]![HousingSearch]![Building]![Population] are combining a request that starts with a form and then jumps to a table.
You are asking access to find data in a form but the information you're most likely trying to access is in a table. I don't quite understand what you're end result is but I think that you most likely want to refer to your information this way [Building]![Population]. Referring to your data this way makes access look at the table of [Building] and then into the field of [Population].
It's been a while since you posted, if you haven't cleared things up already I hope this helps.

Speed of updating database fields SQL

General question on speed:
I have a section of my site where users can update account information. Considering run-time, I was wondering which of the following two approaches would be quicker.
Do a select query on the users existing information, compare it against what the user has submitted in the update form, and only if the field values differ, then updating the fields.
OR
Just overwrite the values in the SQL field, regardless of whether the data in the field matches what has been entered into the form. (This saves me one SQL SELECT request).
Also, just as an aside, does SQL respond differently if attempting to replace data with an exact copy? Is there already some built in method for not replacing what is already there?
Thanks

pass select value and retrieve data from mysql

I'm working on dynamic pages. The scenario goes like this.
Page 1 consists of a drop down menu for me to select.
The selected menu value will pass to the next page URL.
Then this value will be retrieved by the page to compare and filter the MYSQL Table field name.
The table consists of 4 main categories which was the option given to the user to select in page 1.
For each category there will be 30 words stored.
When the user searches for a certain word, it is supposed to ask for an option by displaying the drop down and checking if this value is the same as the value of field id of the table and the word is now used to narrow down to just search in this field instead of all 4 categories.
How to do this? I was working on this for few weeks but I can't solve it.
$ret1 = "SELECT * FROM $db_tb_name WHERE MATCH
('categoryid'='.$selectvalueid.') AND AGAINST ('%$str%' IN BOOLEAN MODE)";
and I have this piece of code and it has wrong syntax.
Please someone help me with some example.
So let me get this straight: at the time you issue your request, you have both a category id $selectvalueid (resulting from the drop down) and a search term $str (resulting from a free text entry?). And you want those rows where the categoryid column of your table exactly matches the $selectvalueid string from your script, while some other column (with what name?) contains the $str value. Is that correct so far?
If it is, your query might look like this:
SELECT * FROM $db_tb_name
WHERE categoryid = '$selectvalueid'
AND wordcolumn LIKE '%$str%'
Note that simply pasting user input variables into SQL queries most likely will make your site vulnerable to SQL injection attacks. So a better way would be using queries with placeholders, and using prepared statements to fill in those placeholders in a safe way when executing the query. How to do that depends on the application language.