I’m trying to:
- take a ‘note’ and its id which is stored in a mysql db (where it matches a username)
- use PHP and store it in an array
- use JSON to make it manageable for the client side processing.
- take each individual note instance with associated note id info.
- display each note in a separate html div for CSS styling
- do it in a way which lets each note in its div be deleted by the user (from the db)
The sql is successful and I can retrieve the notes and display them in the form:
“This is note one”
“This is note two”
but obviously this doesn’t allow for steps 4, 5 and 6 (which is where I’m having problems – how do I take all of this and turn it into something useful for creating a new div for each ‘note’)
$sql = "SELECT note FROM notes WHERE username = '$uname'";
//below is for the next step where I want to also retrieve the note's id
//$sql = "SELECT * FROM notes WHERE username = '$uname'";
$result = mysql_query($sql,$conn);
$i = 0;
while($row = mysql_fetch_assoc($result))
{
$notes[$i] = $row['note'];
echo json_encode($notes[$i]);
$i += 1;
}
I’ve looked into parse, jquery and even arrays after arrays but I’m totally lost now, so help towards this would be massively appreciated.
This is the jquery for creating a new div:
jQuery create new div with ID?
This is seems like a good solution for client side information retrieval from my php array:
http://www.jquery4u.com/json/ajaxjquery-getjson-simple/
If I can work out the other steps I’ll post links for later visitors.