Text search in database column - mysql

im using vb 2010 express edition. I have a database (Sql) and a table "students" in the database. It has a data like this:
StudentId Name Surname Classs
2266 Mike Brown 8
2773 Carol Smith 6
2883 Michel Old 7
2773 Miray Edem 6
27736 Cindy Temiz 7
......................................
......................................
there are lots of students. I want to put a search textbox on my form. User will search a student by name. When user presses a key on search textbox, for example "M" a box will appear and shows students which contains "M". (Mike, Michel, Miray) . It will work like google search. is there any way for me to help for this... Please share your ideas...

You should create a customautocomplete class for your textbox and set its autocomplete
Something like:
Dim tbox As New TextBox
Dim aCol As New AutoCompleteStringCollection
For Each student As String In dt.results("students")
aCol.Add()
Next
tbox.AutoCompleteSource = AutoCompleteSource.CustomSource
tbox.AutoCompleteCustomSource = aCol
tbox.AutoCompleteMode = AutoCompleteMode.SuggestAppend
I prefer VB.NET so I have provided an example in VB.NET as no language was specified.

I always use JQuery's autocomplete: http://docs.jquery.com/Plugins/autocomplete
Build your backend to do the search based on an input string and then have your ui do a json call with the autocomplete to return the results.

Is this a SQL query question or a software question, when you are asking for help? This sounds like a class assignment.
How are you going to be connecting to and querying your database? Are you going to write your query in a stored procedure in the database, or are you going to bind your software objects to the database tables?
Is it a convention at your location to use one kind of data access or query over another?

Related

MySQL query with php contact form 7

I am using contact form 7 in my WordPress site for registration and trying to display the registration info in google data studio.
The field of form_value is like this:
a:9:{s:12:"cfdb7_status";s:6:"unread";s:9:"your-name";s:19:"John";s:10:"your-email";s:28:"john#gmail.com";s:9:"tel-phone";s:8:"20000000";s:15:"your-schoolname";s:2:"LA";s:10:"menu-which";a:1:{i:0;s:6:"Primary";}s:16:"text-schoolother";s:0:"";s:10:"menu-where";a:1:{i:0;s:3:"eDM";}s:10:"text-other";s:0:"";}
I hope to extract the data in the string like: John; john#gmail.com; 20000000; Primary etc.
I have try two way to work on this, the db should be 5.7 in mysql
Custom query, but i am not sure how to do it, i try to queryjson_extract() but it seem an invalid value because of the 'a:9:' in the beginning of the data ...
Filter it on google data studio, i try left() but the string of every result is not the same.
How can I perform it?
Thanks a lot, I finish in substring_index
SUBSTRING_INDEX(SUBSTRING_INDEX(form_value,'";',4),':"',-1) AS Name,
SUBSTRING_INDEX(SUBSTRING_INDEX(form_value,'";',6),':"',-1) AS Email,
SUBSTRING_INDEX(SUBSTRING_INDEX(form_value,'";',8),':"',-1) AS Phone
...

Front-end SQL Search - Dynamically check similar values?

I have a front-end DB search on my website: https://ygoprodeck.com
Currently it checks card names. A user can type in "magician" and get loads of results.
But if a user mis-spells it and types "magican" then no results show.
I've been tracking user inputs and it seems a lot of users are mis-spelling card names and getting no results.
A common example: There are cards with D/D/D in the name but users often type DDD which means they get no results.
Is there a pure SQL method to modify this behaviour or would it need to be implemented through JS/PHP?
Thanks!
How about saving all the mis-spells in new table like
CREATE TABLE misSpells(
misSpell VARCAHR,
correspondingOne VARCHAR
)
Examples:
magician, magician
magican, magician
DDD, DDD
D/D/D, DDD
and query this table for the corresponding one?

How to specify Microsoft Access auto number prefix value based on user selection

I am currently experimenting with Microsoft Access and was curious how one would accomplish this.
I know that one can add a prefix to an autonumber in the format option such as "EMP"000, and each autonumber would fill as EMP001, EMP002, and so on.
What I would like to do is have the "EMP" change dynamically so if my personnel table has them as a Manager for example, it would be listed as MGR003, MGR004, etc.
My thought was to have something like the following in the format section but again am still new to indepth access so please excuse my crude write up.
"SELECT FROM [PersonnelTable].[PersonnelAbbreviation] if [Add Task].[AddTaskPersonnelType]==[PersonnelTable].[PersonnelType];"000
So to recap, I have two tables one "Add Task" the other "Personnel". Would like prefix on Add Task AutoNumber to be based off the abbreviation I have in table Personnel.
Thank you Stack Overflow users!
Simply use a query (air code)
SELECT anydesiredfields, PersonellTable.PersonellType & Format(PersonellTable.PersonellID, "000") as FormattedID
FROM PersonellTable
INNER JOIN AddTask ON PersonellTable.PersonellID = AddTask.PersonellID

Using a REGEX with SQL

I've got a custom searchable member page on a WordPress site running s2member and I have a client that wants to use the mutli select box feature for the "category" data listed members can enter. My current code falls down here as the REGEX I currently use to select the category from the meta_value field only works with the single select box.
Here is the data as it appears in the database field:
s:8:"category";a:1:{i:0;s:17:"Business services";}}
Here is my current AND line in my SQL statement:
AND UMS.meta_value REGEXP '.*\"".$_SESSION['searchfield']."\";s:[0-9]+:\".*".$_SESSION['searchvar'].".\".'
How can I modify the above REGEX to work with the new multi option data? I’ve tried a few things but REGEX isn't a strong point of mine.
Thanks in advance!!

Examples of how to create text fields, size them, and put them in columns on a report

The 1,500 page Access 97 Bible (don't laugh!) that I've been given by my boss to solve his problem doesn't solve my problem of how to solve his problem, because it has nee VBA code.
Let me first make clear that I've made attempts to solve this without (much) coding, and that I've coded quite a bit in VBA already, so I'm basically familiar with most things including recordsets, queries, etc etc but have problems with MS Access limits on how to form a report with data coming from VBA variables. I'm also versatile in most programming languages, but this is not a language problem but rather a "how to/what's possible" problem.
My problem right now is that dragging the query fields into the Detail subform and putting them into cells in columns setting Left and Top with VBA code are moving them alright, but each cell is on a new page. Unfortunately, there is multiple data in each cell that won't conform to the Create Report Guide options available.
So my question is simply this: Can someone point me to working examples of code that create, place, and fill with VBA variable strings, text fields at any coordinate I please on a paper size of my choice?
Edit: The above is not an option, as I understand this will prohibit the client from getting an .mde database. What remains, then, is to merely ask for some sound advice on how to get several rows GROUPed BY weekday and machine (see below) into a recordset or similar for each cell. I guess the best way is to count the number of columns in the table (machines in the sql result) and create 5 rows of these with dummy data, then go through the result rows and place the data in the relevant controls. But if you have ideas for doing this work better and faster, write them as answers.
Sorry for this, I knew there was something I wasn't understanding. Basically, I thought Access supported creating reports dynamically via VBA, ie. "generating pages with data" rather than "preparing a flow of controls connected to datasources". But Access requires that you create an ample amount of dummy, unlinked controls manually, then either fill or hide them and that's how they become "dynamic".
This is for Access 2003 on a remote server accessing local and remote ODBC SQL database tables, if relevant. The goal is to make a week schedule of n columns (n=number of machines at a certain plant) x 5 rows (weekday Mon-Fri), and put 1 or more recordset rows (=scheduled activities for that day on that machine) in each of the "n by 5 table" cells.
If you detect venting frustration in this post I can only ask your forgiveness and hope for your understanding.
So, has many techniques for this:
Ex: 1) using dinamic sql for this:
'Create a function to make sql query
Function MakeMySQlReport(Parameters):
Dim strSql as string
Dim strMyVar as string
strsql = vbnullstring
strsql = "Select " & myVar1 & " as MyFieldVar1, * from myTable where Fieldx =" & Parameters
MyReport.recordSource = ssql
End Function
Ex: 2) create function that returns yours strings:
Function MyString1() as string
MyString1 = 'ABC'
end Function
An in your report, select the textbox will receive the value and type =MyString1()]
I hope this help to you, need more examples?
Solution:
Create many objects manually (grr!)
name them systematically
put them in a Control Array (get all Me.Controls, sift out the ones you're interested in, and put them in an indexed array)
go through the array and change their properties