How do I UPDATE Ajax Score in Mysql

Get help using Construct 2

Post » Mon Jul 07, 2014 4:27 pm

farflamex wrote:Which part isn't working? How are you retrieving the C2 post, are you using isset? I always post my data in the 'data' part of the AJAX box, and then retrieve it in PHP with something like $data = file_get_contents("php://input"); which will put the C2 'data' box in a variable called '$data'. Then I split it to retrieve what I need.

As I said, I'm new to this, spent the entire day trying to work out how I manipulate my loaded objects in PHP (I can retrieve them from my database and put them into objects, but I can't work out how to select different objects in PHP).


I got the bit i was looking for working, , am trying to adapt it now .

When you say you want php to select different objects would you like to expand ?
B
13
S
4
Posts: 60
Reputation: 1,001

Post » Mon Jul 07, 2014 9:02 pm

I've also worked out my problem too :)

I'm used to C2, where I create an object and it just remains in memory as an object forever. I think PHP works like other languages, where the object will be garbage-collected unless you still have at least one reference to it. So in my case, I'm creating an array of objects and then looping through the array to find what I need. It's not as easy as C2 or BASIC but it's useful to learn anyway. I might make most of my game in PHP and just the front-end in C2.
B
25
S
5
G
3
Posts: 446
Reputation: 5,633

Post » Tue Jul 08, 2014 11:14 am

farflamex wrote:I've also worked out my problem too :)

I'm used to C2, where I create an object and it just remains in memory as an object forever. I think PHP works like other languages, where the object will be garbage-collected unless you still have at least one reference to it. So in my case, I'm creating an array of objects and then looping through the array to find what I need. It's not as easy as C2 or BASIC but it's useful to learn anyway. I might make most of my game in PHP and just the front-end in C2.


I am just almost quite nearly there started to explore that which an array is,
can you not just scroll though one in C2 by a +1 function / button
B
13
S
4
Posts: 60
Reputation: 1,001

Post » Tue Jul 08, 2014 3:35 pm

In C2 it's very easy to go through your objects, which is probably my favourite thing about C2. Once you've created your object it lasts for the length of your project, unless you destroy it, and to select certain objects it's very easy to 'pick' the ones you want. It's not so straightforward in other languages, including PHP, but it's not really that hard either. It just feels like a step back to old-fashioned languages.

So for example, if you had 20 objects and you want to select any object which has a certain value, let's say variable A = 1. You just 'pick' them with 'Object A = 1', then anything you do after that only works on those objects. In PHP, you'd need an array of objects and then you need to loop through them, checking each one with 'If A = 1 then'.... it's not really much harder, it just feels a bit more fiddly. There may be a simpler way too but I don't know of one yet.

I was definitely tempted to send all of my database information to C2, do all the processing in C2, then send it back to PHP to save to the database. But it's an extra step when I could just do the whole thing in PHP. Also, I can automate my PHP program to run my game every hour or so (it's turn based).
B
25
S
5
G
3
Posts: 446
Reputation: 5,633

Post » Tue Oct 27, 2015 5:46 am

to farflamex
can u give me tutorial for insert to database from construct .
just simple project
ex :
i have 2 textbox - Name and email
i want to insert name and email to my table on my sql database.

i need help

thanks sir
B
3
Posts: 1
Reputation: 177

Previous

Return to How do I....?

Who is online

Users browsing this forum: jaytrott86, Yahoo [Bot] and 7 guests