- ellie123Asked on July 05, 2014 at 11:48 AM
I have a couple of the dynamic text fields on my form. This is the type where the user can enter one line of text then tap a button and enter another line of text, etc etc.
It works good, except...when the data posts to my db it shows as a comma delimited value (for lackof a better explanation - please see my screenshot at the bottom of this post to see exactly how it shows in my database table.)
I would like to know if I can apply some formatting to this field either at the PHP script stage or at another point.
For instance, with the array fields, I was able to edit the POST data lines and get the output I wanted. (You know I did this for my Array fields: $date=$_POST['date']['0'] .":". $_POST['date']['1'] ." ". $_POST['date']['2'];).
Can I do something similar to get a different output with these dynamic text fields also?
Instead of having them show as "runon" comma values, I'd like to put a line break between each line and ideally number each line.
Here is just an fake example....EDIT: I HAVE POSTED MY REAL CODE A FEW POSTS BELOW
- KadeJMAnswered on July 05, 2014 at 03:32 PM
Are you setting this to be captured from a specific form? Which one if so? Or?
I apologize in advance as my PHP Knowledge is somewhat limited, but I do believe that this should be possible since most Php was built with high customization in mind. You can try to assign a separate array for each of your outputs. Be advised that this may complicate things more involving it more because of the fact that the Dynamic Text output changes on the fly on an as-is and as-needed basis which is a bit unpredictable.
It would be something like:
$plenter23 = explode("\n", $plenter23=$_POST['plenter23']);
In example, you will then need to have an additional code like this:
$str = "nDynamic text1\nDynamic text2\nDynamic text3";
$arr = explode("\n", $str);
This will then convert it into this type of output:
0 => string 'Dynamic text1' (length=8)
1 => string 'Dynamic text2' (length=8)
2 => string 'Dynamic text3' (length=8)
- ellie123Answered on July 05, 2014 at 05:24 PM
Okay...where in the php page above do I put this? I am guessing I screwed up and put in wrong place because I am getting sql syntax error when I submit the form.
Do I put it at the bottom or do I put it in line? If line...where at?
I have this feature on many of my forms. So, I am going to give you the link to a form I am doing now and show you the php code too. I uploaded 2 screenshots so you could see the rest of the php code.
You can find the form I am working on now here: http://form.jotform.us/form/41639129050148
Here you can see where I tried to do the code you said:
Here is the rest of the code on my php page:
Maybe your code goes somewhere at the bottom??
Thank you so much! :)
- KadeJMAnswered on July 05, 2014 at 06:47 PM
I apologize about that. I didn't advise where to place it because I'm not very sure of how your database is set up exactly so that was my reason as to why. Anyhow, I think it could probably go somewhere in the body of your page depending on how you have the rest of your programming done from what I can see so far.
- ellie123Answered on July 05, 2014 at 11:24 PM
Well, as you can see from last 2 screenshots above where I tried it - it didn't work.
i posted my php script page so you could see all my code. There's nothing else on that page.
So, if that was your page where would you put it?
(Those are my db table column names)
- JotForm SupportEltonCrisAnswered on July 06, 2014 at 01:42 AM
That's possible with str_replace, you can use this command to find all the comma and replace it with <br/> tag to bring them into a new line.
$top35 = str_replace(",", "<br/>", $_POST['top35']);
Just replace top35 with your dynamic textbox field name if that's not correct.
Let us know if you need further assistance. Regards!