My demo code from Wednesday’s class re: connecting Processing to PHP and MySQL is now in dropbox. I also added a couple of very simple demo Processing sketches. It’s here: talk_to_processing folder in Dropbox.
Here’s a basic PDO example connecting to MySQL and getting records from a table. Once you’re able to pull records out of a database, remedy you’ll want to be able to get data into the database, treatment often using a form. Check the week4 folder in dropbox for some examples of that. Here’s a tutorial for more info: http://webdevelopingcat.com/php-mysql-tutorial-for-beginners-inserting-rows-with-pdo/
It’s tough to try to translate the syntax from Processing to PHP, more about especially when you’re new to both. Here is a quick example of Object-Oriented Programming in Processing vs. PHP
In Tuesday’s class, viagra here I talked briefly about cookies, information pills but we didn’t have time to go over them in much detail. As promised, here’s some more information. First, I need to correct a mistake in the example code I demo’ed: Setting a cookie requires the built-in PHP function setcookie() and can’t be done setting the $_COOKIE array directly. This explains why my example code was behaving strangely!
Here’s a short (~4 min) video on how to set and retrieve cookies in PHP:
The PHP example files from this week’s classes are now available to download as a zip file: Week 2 files.
What you’ll find in there:
- boxes.php – Dynamically generates rectangular div elements of various sizes. I demo’ed this code in Tuesday’s class
- tinyfacebook (directory) – From Wednesday’s class, prescription it’s a tiny version of Facebook! If you’re in the Tuesday section, buy information pills make sure you take a look at these.
- all_people.php – Lists the users and links them to their profile pages.
- profile.php – The individual profile page. It takes in a user id from the URL and uses $_GET to pull up the right person’s profile.
There is more info about $_GET, and a lot of other things, on my PHP notes page.