fatimamj Posted December 6, 2014 Share Posted December 6, 2014 $id=$_GET['id']; $getnav_data= mysql_query("SELECT `c_name`,`cars_id` FROM `the_cars` WHERE `cat_id`=$id")or die(mysql_error()); // set up loop counter $col_count = 0; // start table and first tr ?> <table cellspacing="0" cellpadding="0" border="0" width="100%" style="margin:40px auto;"> <?phpwhile($nav_data=mysql_fetch_array($getnav_data)){ $get_pic=mysql_query("SELECT `pics_path`,`pics_id` FROM `cars_pic` WHERE `cars_id`=$nav_data[cars_id] ORDER BY `pics_id` DESC LIMIT 1")or die(mysql_error()); $picpath=mysql_fetch_array($get_pic); // if you have output 3 cols then end tr and start a new one if ($col_count == 4) { echo '</tr><tr>'; // and reset the col count $col_count = 0; } // always output the td //this new table after td is just to applay the pic and the name under each other ?><td> <table border="0" width="100%" class="z-table"> <tr><td> <?php echo"<img src='hoss_admincp/$picpath[pics_path]' />";?> </td></tr> <tr><td style=" padding-top: 20px; padding-bottom: 20px; font-size: 14px;"><?php echo"<a href=projects.php?c_id=$nav_data[cars_id] style= 'color:black; text-decoration: none;'>$nav_data[c_name]<br></a>";?> </td></tr> </table> </td> <?php // and count the column $col_count++; } ?></tr></table> hi all, how can i implement the previous code using n div per row,i have tried many times but i failed in every time any tip would appreciated Link to comment Share on other sites More sharing options...
Ingolme Posted December 7, 2014 Share Posted December 7, 2014 What does "n div per row" mean? Link to comment Share on other sites More sharing options...
fatimamj Posted December 7, 2014 Author Share Posted December 7, 2014 instead of tables and td i want to use div and when query i want them to be 4 divs in every row Link to comment Share on other sites More sharing options...
dsonesuk Posted December 7, 2014 Share Posted December 7, 2014 Make tr a outer containing div when count = 0, in count 0 to 3, produce 4 inner divs in place of td, count 4 produce closing outer container div tag and reset, the continue until finished. 1 Link to comment Share on other sites More sharing options...
fatimamj Posted December 7, 2014 Author Share Posted December 7, 2014 first .many thanks all for your time and help,, i am trying to get rid of tables when laying out interface coz i am stuck with tables till today no matter how hard i am trying to deal with divs no need for tables in that case but do not how to do loop using while creating number of divs each row i do not want to use div inside tables Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now