I have a website in which I have a very simple html form that I can fill out. The page was made using php and mysql, so it is also password protected. On this form, I accept input for "Data" and "Activity". With this very small system:
- I can log in with a password
- Enter a "Date" and "Activity"
- The "Date" and "Activity" are stored in a MySQL database
At this point, I think I will just have to build a JSON parser, which there already are many tutorials on this. Such as this and this. what's confusing to me is how to create this JSON page. None of the tutorials really show you how to create a JSON array of the data you are looking for.
This may be a very basic question, but I still very new to Java, PHP, MySQL and totally new to JSON. Please educate me on this topic.
Update:
This code worked for me in the end
<?php
$link = mysql_connect("localhost", "my_db", "password");
mysql_select_db("my_table") or die(mysql_error());
$sql=mysql_query("select * from activity");
while($row=mysql_fetch_assoc($sql)){
$output[]=$row;
}
print(json_encode($output));
mysql_close();
?>