linuh2009 Posted March 26, 2009 Share Posted March 26, 2009 Hi there.I really need help on this and don`t know anybody that could do it ???.What is all about: i have a mysql database and php to display the content from one table in HTML format.What i need is that when i click on a row (doesn`t matter what cell) to give me an extra row(show/hide) witch will display the content from a column inside mysql, same table and it is not displayed normally.Using HTML and js i could do it, but since i`m new to php & MySQL i just don`t know how to do this. In html i did that : # <html> # <head> # <style type="text/css"> # .hide # { # display: none ; # } # # .show # { # display: block; # background-color: #d0d0d0; # } # </style> # <script type="text/javascript"> # function showHide(id) # { # if (document.getElementById) # var obj = document.getElementById(id); # if (typeof(obj)=='undefined' || obj==null) return; # if (obj.className == 'hide') obj.className='show'; # else obj.className='hide'; # } # </script> # </head> # <body> # <table border="1"> # <tr> # <td>HEAD1</td> # <td>HEAD2</td> # <td>HEAD3</td> # <td>HEAD4</td> # </tr> # <tr onclick="showHide('rnd1');"> # <td>ROW1</td> # <td>ROW1</td> # <td>ROW1</td> # <td>ROW1</td> # </tr> # <tr id="rnd1" class="hide"> # <td colspan="4">Describe row 1</td> # </tr> # <tr onclick="showHide('rnd2');"> # <td>ROW2</td> # <td>ROW2</td> # <td>ROW2</td> # <td>ROW2</td> # </tr> # <tr id="rnd2" class="hide"> # <td colspan="4">Describe row 2</td> # </tr> # </table> # </body> # </html> In PHP i use that to display it after the table header. <? while($row = mysql_fetch_array($result)) { echo "<tbody align='center'>"; echo "<tr>"; echo "<td align='left'>". $row['id'] ."</td>"; echo "<td align='left'>". $row['denumire'] . "</td>"; echo "<td>" . $row['nrinv'] . "</td>"; echo "<td>" . $row['um'] . "</td>"; echo "<td>" . $row['cantitatea'] . "</td>"; echo "<td>" . $row['achizitie'] . "</td>"; echo "<td>" . $row['initial'] . "</td>"; echo "<td>" . $row['actual'] . "</td>"; echo "<td>" . $row['locatia'] . "</td>"; echo "</tr>"; echo "</tbody>"; echo "<tr>"; } echo "</table>"; mysql_close($con); ?> I just don`t know how to do this in php as in HTML/JS. Thank you for your time and i hope i managed to explain what i need, but most of all i hope someone could help me. I`m trying to do that for 3 days now and i`m out of time....ThankYou. Quote Link to comment Share on other sites More sharing options...
POG1 Posted March 26, 2009 Share Posted March 26, 2009 Why do you need like 14 echos in a row :S And i dont understand what your trying to do. Do you want it so that when you click a row it will add another empty row at the bottom? Quote Link to comment Share on other sites More sharing options...
linuh2009 Posted March 26, 2009 Author Share Posted March 26, 2009 Ok.For php to display i could use this after table header <? echo "</tr>\n"; while($row = mysql_fetch_row($result)) { echo "<tr class='entry show'>"; foreach($row as $cell) echo "<td><a onClick=\"toggle_it('pr1')\">$cell</a></td>"; echo "</tr>\n"; } mysql_free_result($result); ?> What i need is this example : http://daagest.feaa.uaic.ro/teste/example1/index.html But to get all the content from MySQL, with a lot more rows ofc.... When click on a row`s cell to give an extra row right under the one i clicked, wich will contain some data stored in another mysql column in same table, column displayed only when clicked on row.....Thank you. Quote Link to comment Share on other sites More sharing options...
linuh2009 Posted March 26, 2009 Author Share Posted March 26, 2009 Sorry for my mistake.In php i could use this code after table`s header. <? echo "</tr>\n"; while($row = mysql_fetch_row($result)) { echo "<tr class='entry show'>"; foreach($row as $cell) echo "<td>$cell</td>"; echo "</tr>\n"; } mysql_free_result($result); ?> Instead of all thoose "echoes"...:S Quote Link to comment Share on other sites More sharing options...
POG1 Posted March 26, 2009 Share Posted March 26, 2009 In the query select all the needed fields and put them into the hidden parts.. Quote Link to comment Share on other sites More sharing options...
linuh2009 Posted March 26, 2009 Author Share Posted March 26, 2009 No matter what i do just can`t get it to work....how i was saying i`m totaly new with php.I`ve start reading man pages.....don`t see other solution.... Quote Link to comment Share on other sites More sharing options...
POG1 Posted March 26, 2009 Share Posted March 26, 2009 All you need to do is echo the additional values in the hidden area. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.