collapslable database driven rows
Please refer follwoing code
Code:
$result = mysql_query("select * from topic");
echo "<div>";
echo "<table>
<tr>
<th>topicid</th>
<th>TopicName</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr bgcolor='#736A6E'>";
$topicid = $row['TopicID'] ;
echo "<td>" . $row['TopicID'] . "</td>";
echo "<td>" . $row['TopicName'] ."</td>";
//********************************************************
//Child table rows
//**********************
echo "</tr>";
echo "<tr><td></td></tr>";
echo "<tr><td></td></tr>";
}
echo "</table>";
echo "</div>";
i need child rows disbaled initailly and then enabled when parent rows clcik..
i wnat this using php jquery /database
Thanks
Re: collapslable database driven rows
Solution1:
Load all the parent and child rows at first(echo out all of them). And hide the child rows of all parents, using jQuery's hide() at document ready state. Also, write the jQuery code to enable the corresponding child rows upon clicking the respective parent.
Solution2:
List out all the parent rows. And write the click event(in jQuery) for these parents to load the respective child rows via jQuery get().
See these for some of the effects: http://api.jquery.com/category/effects/basics/
I have made a quick example, you could test it here: http://jsfiddle.net/BGVzw/
:wave:
Re: collapslable database driven rows
thanks for reply and sugessting me
can u make sample programmm .. i have already database driven code ..in thread
Re: collapslable database driven rows
Quote:
Originally Posted by
dot_net_help
thanks for reply and sugessting me
can u make sample programmm .. i have already database driven code ..in thread
You didn't checked the example that I have posted ?:confused:
:wave:
Re: collapslable database driven rows
coe is like thsi but it hide child rows of Ist parents only
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>PHP Login with jQuery AJAX</title>
<script type="text/javascript" src="jquery-1.5.2.min.js"></script>
<script>
$(document).ready(function() {
$('#id1').hide();
});
</script>
</head>
<body>
<?php
$con = mysql_connect("127.0.0.1","root","");
if (!$con)
{
//echo "not Connected";
exit("Connection Failed: " . $con);
}
else
{
echo "Connected";
// Insertion into database
mysql_select_db("directory") or die(mysql_error());
//mysql_query("INSERT INTO products (ProductName) VALUES ('Tabbusamm REcord')")
//or die(mysql_error());
// Insertion into database
$result = mysql_query("select * from topic");
echo "<div>";
echo "<table>
<tr>
<th>topicid</th>
<th>TopicName</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
$topicid = $row['TopicID'] ;
echo "<td>" . $row['TopicID'] . "</td>";
echo "<td>" . $row['TopicName'] ."</td>";
//*************************************************************************
$result1 = mysql_query("select * from comment where topicID = '$topicid' ");
echo "<table id='id1'>";
while($row = mysql_fetch_array($result1))
{
echo "<tr>";
echo "<td>" . $row['TopicID'] . "</td>";
echo "<td>" . $row['Comments'] . "</td>";
echo "</tr>";
}
echo "</table>";
//******************************************************************************
echo "</tr>";
echo "<tr><td></td></tr>";
echo "<tr><td></td></tr>";
}
echo "</table>";
echo "</div>";
mysql_close($con);
}
?>
</body>
</html>
</html>
any help