MySQL query with php contact form 7 - mysql

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

Related

How do I reduce the number of characters in an input string/varchar in MySQL

I basically have two tables tbl_feedback and tbl_notification that both get values inserted in them through a stored procedure whenever a person submits a feedback.
What I'm aiming for is getting a "shortened" version of a message column inserted into tbl_notification (say 60 characters max) so a notification only shows a preview of the actual message.
Is this possible using a MySQL function or do I have to resort to handling it via PHP (shortening an output string before echoing it)
The LEFT function was what I was looking for. Thanks, Paul.
I wish that google pointed me straight to this function.
w3resource on LEFT function

Query Google Admin User directory comparing parameters

I'm trying to filter my users list by comparing two parameters
query="EmployeeData.EmployeeID=externalId"
EmployeeData.EmployeeID is a custom schema that is populated, with a cron job, with the same value as externalId.
Of course I let the cron do the field copy only if necessary, this is the reason I'm trying to filtering the users list.
In the way i wrote seems that the query trying to looking for a value "externalId" into the EmployeeData.EmployeeID ignoring that "externalId" is a even a field
any suggestion?
The way your code is written, the query sent to Google's servers is as you correctly guessed the following:
EmployeeData.EmployeeID=externalId where your actual externalId is not sent but rather the string "externalId".
To replace this string for the actual value of your variable, you can use what is called "string concatenation" 1. To do it, you just need to modify your code as shown below:
query="EmployeeData.EmployeeID=" + externalId;
This way, the query will be sent as you need to Google's servers.

Using SELECT FROM WHERE in a report

Hi & thanks for reading/helping!
I have a simple table with email addresses and domain names. In an equally simple form I can list in a listbox the email addresses that go with each domain name using:
SELECT Emails.EmailAddr FROM Emails WHERE Emails.[DomainName]=Form![DomainName];
and it works perfectly. However despite trying every permutation going I CANNOT make the same thing work in a report :-( even if I try saving the form as a report. Can anybody help me understand why this doesn't work ...
SELECT Emails.EmailAddr FROM Emails WHERE Emails.[DomainName]=Report![DomainName];
If I omit the "Report!" then I get a list of all email addresses but with every other reference I get nothing at all or an error.
My forehead is bruised from banging it on the table!
Jimmy
The syntax for referring to report controls is the following:
Reports!ReportName!ControlName
You should be able to use that in your SQL clause.

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!!

Text search in database column

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?