|
I'm having a hard time passing an array of values via POST. Now you might say "wow you're dumb" and maybe I am, but let me explain. I am using jQuery on a page to add some additional rows to a table within a form that gets submitted, the number of rows needs to be dynamic and reloading the page and adding it via php isn't an option as there's some pretty heavy lifting being done on this page and it would take 5-10 seconds each time they wanted to add a new input field. So I've worked around this by using jQuery. Why jQuery you ask? This has to run in old as balls browsers so I can't use something else. Here is the situation so far. When I post it will pass the value in the first row of the table, naturally this row exists within the hard coded PHP as it's the reference row. I'm adding additional rows into the DOM using this handy little script: code:
Is it that a POST won't pick up these fields that are added using jQuery or are they just not formatted properly? The hardcoded row looks like this in my html file: code:
Please, any assistance would be hugely helpful as this project is due by EOD Sunday and this is really my last blocker before I submit it for client approval.
|
# ¿ Jun 27, 2020 04:29 |
|
|
# ¿ May 21, 2024 07:47 |
|
Banditu posted:Hello Mode6, Hm. Ok interesting. How are you picking it up in the $_POST on the receiving page?
|
# ¿ Jun 27, 2020 14:14 |
|
Banditu posted:To check the value I just used print_r : Awesome. I've been checking it the same way and only getting one of the values. Something fishy going on with this. Edit: turns out I'm just bad at html and had two opening body tags which may or may not have been causing it not to work. Removed the additional body tags and made the form tag outside the table instead of inside and now it works. Not sure which is the reason but it works. Thanks for validating that it was a me issue not a code issue. Really helped. ModeSix fucked around with this message at 14:47 on Jun 27, 2020 |
# ¿ Jun 27, 2020 14:34 |
|
I have a very particular issue I am trying to tackle with string sorting and I've got it 80% of the way there. Let's say I've got 5 strings as follows: 2 for 1 - 6" Apple Pies 2 for 1 - 12" Apple Pies 50% Off - Banana Cakes 50% Off - 30 Carrot Cakes 2 For 1 - Dead Thing 2 for 1 - 5 Zebra Skins Right now I can get them to sort like this: 50% off - Banana Cakes 2 for 1 - Dead Thing 2 for 1 - 6" Apple Pies 2 for 1 - 12" Apple Pies 50% Off - 30 Carrot Cakes 2 for 1 - 5 Zebra Skins But ideally I'd like them to be sortable in alphabetical order, then by quantity/size if there is one as shown in the top list. Taking into account that 6 is before 12 (as we all know numbering in php is a pain). I've gotten it most of the way there using explodes, substrings etc. but I can't figure out how to merge with leading numbers, without leading numbers together to get a pure alphabetical, then size/quantity list. If someone can point me in the right direction on thi it would be super helpful. My spaghetti mess looks like this right now: code:
|
# ¿ Dec 17, 2020 23:58 |
|
Does anyone have any recommendations for creating a REST API that is backed by an existing MySQL database? I've taken a look at Lumen, but honestly I can't figuring the routing on it, even though syntactically it looks almost exactly like creating a REST API in NodeJS(Express). The documentation on Lumen is so poor I can't figure out to get it to work. ModeSix fucked around with this message at 04:27 on Jan 7, 2021 |
# ¿ Jan 7, 2021 04:18 |
|
musclecoder posted:How robust does it need to be? Is this just a couple of endpoints? If so, any modern framework (Symfony, Laravel) will allow you to set one up very easily, provide serializers and normalizers to convert your data to/from one format to another. If it needs to be very robust, really respect HATEOS, HTTP, REST, etc then you may want to look into API Platform: https://api-platform.com/ It's going to be pretty simple, using it to generate endpoints for a mobile application that needs access to some site/user data from the main site and doing direct DB calls is a no-no for many reasons. I just need to get some responses from some joins off the database, be able to put updates and validate auth. Simple is all I need. I'll take a look at Symfony, I think Lumen uses it in there because I was getting some good errors off of it that referenced Symfony.
|
# ¿ Jan 7, 2021 14:31 |
|
rt4 posted:You could probably use this to automate the entire thing This looks like exactly what I am looking for. Brilliant, thanks!
|
# ¿ Jan 7, 2021 20:17 |
|
I am trying to find the highest value for a given combination of array keys. The array I have is thus: code:
I've been banging my head on this all day and can't come up with a working solution.
|
# ¿ Feb 9, 2021 22:20 |
|
Biowarfare posted:some abomination similar to I already asked on the SQL thread, and I thought I understood the answer, but don't! code:
|
# ¿ Feb 10, 2021 01:13 |
|
Jeffrey of YOSPOS posted:Here's an example from the post above for comparison: I checked this in both light and dark mode and I don't think the code=php tag is a good solution for PHP code. It reaches mostly acceptable levels on light mode, but downright bad on dark mode.
|
# ¿ May 19, 2021 12:59 |
|
astral posted:How about now? Thanks to some good feedback in the technical forum, the code highlighting system has been updated. Additional code highlighting improvements will be forthcoming. The blue on blue is still... difficult to read. This is using the PHP tag. It's like there's a smurf hiding in a blueberry patch. On the code=php tag it's super easy to read. You can check this post as a reference: https://forums.somethingawful.com/showthread.php?noseen=1&threadid=2802621&pagenumber=219&perpage=40#post514831916 ModeSix fucked around with this message at 02:47 on Jul 2, 2021 |
# ¿ Jul 2, 2021 02:44 |
|
Good Sphere posted:I'm trying to get php installed on macOS, using Intel processor. I've had it before, but I understand there has been some changes, and the brew install is your best bet. Seems to be installed, although php is showing the script instead of the rendered page in my browser. I'm using localhost in the address bar. Your best and easiest bet might be XAMPP: https://www.apachefriends.org/download.html
|
# ¿ Jan 15, 2022 23:24 |
|
It's funny, I just solved this problem for myself just yesterday on something I was working on. You could also do something like this: code:
|
# ¿ Mar 8, 2022 03:04 |
|
Good Sphere posted:Thanks for the info. I tried your suggestions. Used echo(shell_exec("open -a 'myAppName' file.txt"));, also with full path, and even without specifying the app name. Maybe it's how things are configured on the php end. In the php.ini search for disable_functions and make sure shell_exec is not listed there. If it is, remove it, save and restart XAMPP. ModeSix fucked around with this message at 01:21 on Jul 16, 2022 |
# ¿ Jul 16, 2022 01:17 |
|
edit: nevermind, it didn't actually do it right.
ModeSix fucked around with this message at 21:42 on Feb 25, 2023 |
# ¿ Feb 25, 2023 21:15 |
|
Here's a solution ChatGPT gave me after a bit of massaging. php:<?php // Step 1: Create an array of 10,000 nodes $nodes = array(); for ($i = 0; $i < 10000; $i++) { $nodes[$i] = array(); } // Step 2: Generate random connections for each node $letters = range('A', 'U'); // Step 2a: Create the "main group" of nodes $main_group = array(); for ($i = 0; $i < 1000; $i++) { $main_group[] = rand(0, 9999); } shuffle($main_group); foreach ($main_group as $i => $node) { $num_connections = min(count($main_group) - 1, rand(1, 20)); $available_connections = array_diff($main_group, array($node)); shuffle($available_connections); for ($j = 0; $j < $num_connections; $j++) { $connection_letter = $letters[$j]; $connection_node = $available_connections[$j]; $nodes[$node][$connection_letter] = $connection_node; $nodes[$connection_node][$connection_letter] = $node; } } // Step 2b: Connect the remaining nodes to the main group $remaining_nodes = array_diff(array_keys($nodes), $main_group); foreach ($remaining_nodes as $i => &$node) { $num_connections = rand(1, 20); $available_connections = array_merge($main_group, array_diff($remaining_nodes, array($node))); shuffle($available_connections); for ($j = 0; $j < $num_connections; $j++) { $connection_letter = $letters[$j]; $connection_node = $available_connections[$j]; $nodes[$node][$connection_letter] = $connection_node; $nodes[$connection_node][$connection_letter] = $node; } } ?> ModeSix fucked around with this message at 03:01 on Feb 27, 2023 |
# ¿ Feb 27, 2023 02:57 |
|
|
# ¿ May 21, 2024 07:47 |
|
Ranzear posted:You'll spend more time futzing with it and then vetting what it spits out than it would take to write it yourself, cleaner to read, faster, and more expansible, in the first place. I definitely agree with this statement and can attest I had to get it to redo a few things a few times to get it to a useable state. The code I put up above is by no means optimal or easy to read. It gets the job done, sub optimally, but as Ranzear said how expandable or flexible it is is likely low.
|
# ¿ Feb 28, 2023 04:20 |