alexandre Posted November 6, 2022 Share Posted November 6, 2022 i am not sure how i should proceed , as far as i went on this , it turned out that i am unable to make a div go underneath all the rows diplayed so it can serve as body for the ranking section. echo "<div class='rankingtrue2'> <div class='ranking_wrapper'> <table class='rankingtable'> <tr> <td>username</td><td>last donation</td><td>total donated</td><td>total_received</td> </tr> <tr> <td class='remain1'>" . $result_row['users_name']. "</td> <td class='remain2'>" . $result_row['donation']. "</td> <td class='remain3'>" . $result_row['total_donated']. "</td> <td class='remain4'>" . $result_row['total_received']. "</td> </tr> </table> </div> </div><br><br>"; } } this is an example of the grid formatting, now whatever i try the divs are acting only on a single row. if anyone have an idea how to do that i would appreciate. Quote Link to comment https://forums.phpfreaks.com/topic/315497-trying-to-make-a-div-parent-of-all-rows-pulled-from-database/ Share on other sites More sharing options...
Solution Barand Posted November 6, 2022 Solution Share Posted November 6, 2022 At the moment you appear to have something like this start loop { <div> <div> <table> <tr> headings </tr> <tr> data </tr> </table> </div> </div>} } end loop It sound like what you want is this <div> <div> <table> <tr> headings </tr> start loop { <tr> data </tr> } end loop </table> </div> </div>} Quote Link to comment https://forums.phpfreaks.com/topic/315497-trying-to-make-a-div-parent-of-all-rows-pulled-from-database/#findComment-1602258 Share on other sites More sharing options...
alexandre Posted November 6, 2022 Author Share Posted November 6, 2022 18 minutes ago, Barand said: At the moment you appear to have something like this start loop { <div> <div> <table> <tr> headings </tr> <tr> data </tr> </table> </div> </div>} } end loop It sound like what you want is this <div> <div> <table> <tr> headings </tr> start loop { <tr> data </tr> } end loop </table> </div> </div>} yes i was indeed trying to open and close a div around the while loop but without any success . this seems more like what i need and will try it right away. i just havve one more question, do i echo just once or both when i open the div and when i close it ? Quote Link to comment https://forums.phpfreaks.com/topic/315497-trying-to-make-a-div-parent-of-all-rows-pulled-from-database/#findComment-1602259 Share on other sites More sharing options...
Barand Posted November 6, 2022 Share Posted November 6, 2022 You need 3 sets of output... before the loop inside the loop after the loop Quote Link to comment https://forums.phpfreaks.com/topic/315497-trying-to-make-a-div-parent-of-all-rows-pulled-from-database/#findComment-1602260 Share on other sites More sharing options...
alexandre Posted November 6, 2022 Author Share Posted November 6, 2022 it worked , the div is under the ranking but i cant give it a height it will stay the size of the row, i tried to set the height and max height but it wont move, could it be needing a css property to expand it over a certain limit or am i missing something? i also want to keep the repetitive headings , i believe this way it is adding a bit of a separation and readability between the records and their meanings. Quote Link to comment https://forums.phpfreaks.com/topic/315497-trying-to-make-a-div-parent-of-all-rows-pulled-from-database/#findComment-1602262 Share on other sites More sharing options...
ginerjm Posted November 6, 2022 Share Posted November 6, 2022 And I think you only need the one div to wrap the entire table in. And yes - use the <th> tags for your headings and then don't echo them out any more. // Begin table echo " <div class='tbl_box'> <table class='rankingtable'> <tr> <th>username</td> <th>last donation</th> <th>total donated</th> <th>total_received</th> </tr> "; // data rows into table while($result_row ->fetch()) { echo " <tr> <td class='remain1'>{$result_row['users_name']}</td> <td class='remain2'>{$result_row['donation']}</td> <td class='remain3'>{$result_row['total_donated']}</td> <td class='remain4'>{$result_row['total_received']}</td> </tr> "; } // end the table and div echo " </table> </div> "; Note the use of {} to wrap your row data fields instead of what you were doing. as for the height of your headings row: That' s simply some Css that you could add for that row. Or simply add a <br> tag to the heading text Quote Link to comment https://forums.phpfreaks.com/topic/315497-trying-to-make-a-div-parent-of-all-rows-pulled-from-database/#findComment-1602263 Share on other sites More sharing options...
alexandre Posted November 6, 2022 Author Share Posted November 6, 2022 14 minutes ago, ginerjm said: And I think you only need the one div to wrap the entire table in. And yes - use the <th> tags for your headings and then don't echo them out any more. // Begin table echo " <div class='tbl_box'> <table class='rankingtable'> <tr> <th>username</td> <th>last donation</th> <th>total donated</th> <th>total_received</th> </tr> "; // data rows into table while($result_row ->fetch()) { echo " <tr> <td class='remain1'>{$result_row['users_name']}</td> <td class='remain2'>{$result_row['donation']}</td> <td class='remain3'>{$result_row['total_donated']}</td> <td class='remain4'>{$result_row['total_received']}</td> </tr> "; } // end the table and div echo " </table> </div> "; Note the use of {} to wrap your row data fields instead of what you were doing. as for the height of your headings row: That' s simply some Css that you could add for that row. Or simply add a <br> tag to the heading text i tried all the properties i know in css to try and make the div expand but there is nothing that makes it move, just as if it was again affecting a single row. and for the headings i want to keep them repetitive do you think it is affecting the wrapping div if i leave the headings inside the loop and just put the table around the loop with the needed divs? (the other divs are simply for adding some borders to the design). also i didnt know that i could use brackets to isolate a variable in a string, if i understood right , thank you for the advice it seems like a good practice . Quote Link to comment https://forums.phpfreaks.com/topic/315497-trying-to-make-a-div-parent-of-all-rows-pulled-from-database/#findComment-1602266 Share on other sites More sharing options...
ginerjm Posted November 6, 2022 Share Posted November 6, 2022 2 minutes ago, alexandre said: make the div expand What does this mean? I thought we were talking about a row? You want to output a set of headings for ever data row in your report/screen? Kinda messy to me. Quote Link to comment https://forums.phpfreaks.com/topic/315497-trying-to-make-a-div-parent-of-all-rows-pulled-from-database/#findComment-1602267 Share on other sites More sharing options...
alexandre Posted November 6, 2022 Author Share Posted November 6, 2022 i think i can fix that boxing issue by simply setting the css and adding divs for each section of the table making it form a boxing background style . Quote Link to comment https://forums.phpfreaks.com/topic/315497-trying-to-make-a-div-parent-of-all-rows-pulled-from-database/#findComment-1602268 Share on other sites More sharing options...
ginerjm Posted November 6, 2022 Share Posted November 6, 2022 you've lost me. Good luck. Quote Link to comment https://forums.phpfreaks.com/topic/315497-trying-to-make-a-div-parent-of-all-rows-pulled-from-database/#findComment-1602269 Share on other sites More sharing options...
alexandre Posted November 6, 2022 Author Share Posted November 6, 2022 3 minutes ago, ginerjm said: What does this mean? I thought we were talking about a row? You want to output a set of headings for ever data row in your report/screen? Kinda messy to me. no , i wanted to make a div serve as body like kind of background for the whole table, so it doesnt look like a set of rows floating in the void Quote Link to comment https://forums.phpfreaks.com/topic/315497-trying-to-make-a-div-parent-of-all-rows-pulled-from-database/#findComment-1602270 Share on other sites More sharing options...
ginerjm Posted November 6, 2022 Share Posted November 6, 2022 Well you don't need multiple divs to accomplish that. One is enough. Just add the CSS to it. Quote Link to comment https://forums.phpfreaks.com/topic/315497-trying-to-make-a-div-parent-of-all-rows-pulled-from-database/#findComment-1602272 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.