I've looked at the Javascript code and have found what the problem is!
It was building the array structure as a string, so was passing a stringified string
I've amended it and it now works ok.
Sorry if I have offended you, but thanks for the help
Sorry if I am being dense, but as I said new to JSON - have only ever used $_POST before, and I'm doing this to help out a local charity in my spare time so really appreciate your help.
I have been using Googled examples to set up the code, assuming it to be correct, so have removed the header...
Thanks for your help.
Back in the office and have loaded correct version of HTML document, and tried it out, but am now getting an error in the PHP foreach line.
However I tried your code and that worked as expected.
I have noted though that the print_r output is different to the output seen...
Have just been talking to the guy who wrote the original javascript, which has never been used until now, and he says it's a mistake - the JSON output should have been:
[
{
"id": 1,
"stext": "a string",
"sdate": "09/11/2023",
"bid": "7",
"cid": "6"...
I have a json_decoded string passed by AJAX array in the format :
Array (
[dta] => [
{ "a" : 1, "b" : "string" , "c" : ""},
{ "a" : 8, "b" : "string 2" , "c" : "12/12/2022"}
]
[vars] => [
7,
12
]
)
The items pointed to by dta need to be looped through...
I have written a program for internal use using, mainly, PHP, but also has a lot of Javascript. It works absolutely fine using WIndows devices (including Windows phones), Android phones, and for the most part iPhones, but there are some items that don't work properly using the latter.
Generally...
Thanks for the response feherke,
As you have probably guessed I am new to Javascript/PHP, in the process of (slowly) converting a desktop, Delphi, system to web-based.
Had never even thought about the situation you describe, and haven't looked at JSON before.
Must admit web programming is...
Have found what the problem is: It's the php variable $invitetext.
If it contains any line breaks (which it should do because the text is going to be an email body) then it doesn't work. If a single line of text it works ok.
Have to insert a unique a unique code (llbb) in the PHP variable...
Have form that has a select list, change button, textarea and submit button. When page is loaded PHP sets up variables, and the textarea and submit button are disabled with the textarea displaying placeholder text.
What should happen is when the user selects an item from the list and then...
During this lockdown period I have decided to help a local sports charity by finishing-off an online management system written using, primarily bootstrap 4 and php.
One thing I want to do is a system to set up dates that sessions will be available for forthcoming term. So I set up a form with 6...
I have just about finished my first ever PHP project (a Sports Club Management System converted from a Del[phi app) and I am left with one thing to complete. The attendance register. More specifically saving the data back to the MySQL table. Everything else works fine
Basically the attendance...
Thanks for response.
The echo came back as unknown field A.class_id in field roster
So I changed all the occurrences of A. to attendance. and all the B. to memberdetails (obviously removing the AS A and AS B) and it now runs ok.
Puzzling to understand why that should happen.
Hi,
If I enter the following SELECT statement in phpMyAdmin it works ok
SELECT A.class_id, A.attend, A.mem_id, B.firstname, B.lastname FROM attendance AS A INNER JOIN memberdetails AS B ON B.mem_id = A.mem_id WHERE A.class_id=5 ORDER BY B.lastname, B.firstname ASC
but if I try the following...
I finally sorted it by combining code I found on the web. Probably not the most efficient code, but it works!
Function to create string of all items in listbox:
<script>
$(document).ready(function()
{
$("#submit1").click(function()
{
$("#form1").submit(function()
{...
Right her is an extract of my code
At the top (before the HTML tag
<?php
require_once 'session.php';
require_once 'conn.php';
/* Code to get username to display on HTML page */
$acc_query = $conn->query("SELECT * FROM `admin` WHERE `admin_id` = '$_SESSION[admin_id]'") or...
Apologies for not replying sooner, have been away for a few days with no access to the internet.
I will be back in the real world soon, and will upload a synopsis of what I have done so far.
Basically I am using some JQuery I found online to control the 2 listboxes and the buttons that move...
Another newbie question!
I know you can get the option value of selected items in a listbox from the $_POST variable, but is it possible to determine all items in a listbox (selected and unselected) following a post submit.
What I am trying to achieve is:
A form has 2 listboxes. By selecting...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.