higfox
higfox

Reputation: 87

Todo list in php

I'm building a simple todo list application in PHP.I am displaying the titles of all the todo list on one page via ajax using the following code

 $sql2 = mysql_query("SELECT id, todo FROM todo");

while($row = mysql_fetch_array($sql2))
{
$todo1 = $row["todo"];
$todofeed.='

<ul>
    <li>' . $todo1 . '</li>
</ul>   

';
  }
  print "$todofeed";

Now i want to create an interface in such a way that the user clicks on one todo list title and all items in that list are displayed via some jQuery effect...any way around this?? i jus need a direction...thanks :)

Upvotes: 0

Views: 3954

Answers (3)

Ofir Baruch
Ofir Baruch

Reputation: 10356

Fetch all the items of that todo list in a div with display:none. Then , use Jquery .click to change its display attribute to visible.

<script>
$("#todolist_title").click(function() {
  $("#todolist_items").css('display' , 'visible');
});
</script>

<div id='todolist_title'>Title</div>
<br />
<div id='todolist_items' style='display:none'>
1.Item1<br />
2.Item2<br />
3.Item3<br />
</div>

Upvotes: 1

Adeel Mughal
Adeel Mughal

Reputation: 736

Please add this code on page where you want to populate todofeeds

<script type="text/javascript">
function todolist() {
$('#todolist').load("PHP Page Path Where you execute Query").slideDown();   
}
</script>

<div id="todolist" style="display:none"></div>

Please include Database connection on PHP page.

Upvotes: 0

Eydun
Eydun

Reputation: 534

Here is a nice tutorial on how to create a todolist application with PHP and JQuery: AJAX-ed Todo List With PHP, MySQL & jQuery

Upvotes: 1

Related Questions