Results 1 to 5 of 5

Thread: collapslable database driven rows

Hybrid View

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2007
    Posts
    270

    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

  2. #2
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    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/


    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2007
    Posts
    270

    Re: collapslable database driven rows

    thanks for reply and sugessting me
    can u make sample programmm .. i have already database driven code ..in thread

  4. #4
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: collapslable database driven rows

    Quote Originally Posted by dot_net_help View Post
    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 ?


    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2007
    Posts
    270

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width