phphelp! Posted February 4, 2011 Share Posted February 4, 2011 Hello, I need some help modifying some code. I would like to change the layout to show more then currently offered. As of now I have a layout that shows either 3 or 10 images. I tried to change the numbers, but no luck and I can not seem to be able to change to view more. Any help would be great! // image list $mysqlDataImage = mysql_query( "SELECT * FROM $DB_IMAGE where collectionID=$cat $where ORDER BY $order_by" ); $dataLength = mysql_num_rows( $mysqlDataImage ); $totalImages = $dataLength; //$cat_scrollview = 3; //FORCE SCROLLER if($scrollview == "smaller"){ $cat_scrollview = 0; } //User Override //SWITCH SCROLL LAYOUT BASED ON VIEW : HANDLES COLUMNS, ROWS, PAGES AND SHOW ALL if (($cat_scrollview == 3)||($scrollview == "bigger")){ $PAGE_SIZE = 3; //how many pics per page, all set in html $rowDefault = 1; //row default-changes the most $colDefault = $totalImages/ 1; //columns default use to breakup columns //echo "cols=".$colDefault; //echo "totalimage=".$totalImages; //See getNumberOfRows() $totalPages = $totalImages/$PAGE_SIZE; $cat_scrollview = 3; $scrollview = "bigger"; }else{ $PAGE_SIZE = 10; //how many pics per page, all set in html $rowDefault = 2; //row default-changes the most $colDefault = $totalImages/ 2; //columns default use to breakup columns //echo "cols=".$colDefault; //echo "totalimage=".$totalImages; //See getNumberOfRows() $totalPages = $totalImages/$PAGE_SIZE; $cat_scrollview = 0; $scrollview = "smaller"; } I am new to PHP so please be kind (and explain slowly) Thank you! Quote Link to comment https://forums.phpfreaks.com/topic/226698-layout-view/ Share on other sites More sharing options...
drisate Posted February 4, 2011 Share Posted February 4, 2011 Whats the $where var? At the end of the page add this line echo "SELECT * FROM $DB_IMAGE where collectionID=$cat $where ORDER BY $order_by"; And post the result here Quote Link to comment https://forums.phpfreaks.com/topic/226698-layout-view/#findComment-1169931 Share on other sites More sharing options...
phphelp! Posted February 4, 2011 Author Share Posted February 4, 2011 Thank you a lot: it gave me SELECT * FROM 2010_image where collectionID=1 ORDER BY orderIndex desc Quote Link to comment https://forums.phpfreaks.com/topic/226698-layout-view/#findComment-1169934 Share on other sites More sharing options...
Maq Posted February 4, 2011 Share Posted February 4, 2011 (Please use tags when posting code) Quote Link to comment https://forums.phpfreaks.com/topic/226698-layout-view/#findComment-1169938 Share on other sites More sharing options...
drisate Posted February 4, 2011 Share Posted February 4, 2011 The $where var is empty ... theres no limit in the SQL and the vars seems ok ... Unless you post the hole code theres nothing i can do to help at this point ... But if your looking to post X number of images by X number of line you can try this code i made <?php $mypage = "media_image.php?"; // Keep the ? at the end or finish it with & if you already have vars $nb_per_page = 9; $image_folder = "images"; $col = 3; if ($_GET == "") { $num_page = 1; } else { $num_page = $_GET['page']; } $offset = ($num_page - 1) * $nb_per_page; $nb_images = @current(@mysql_fetch_assoc(@mysql_query("SELECT count(id) FROM $DB_IMAGE"))); $re_page = $num_page * $nb_per_page; $ree_page = $re_page - $nb_per_page; $row = 0; // Start of the table print ('<table border="0" cellpadding="3" cellspacing="3" width="100%" id="table1"><tr>'); // Start the loop $select = mysql_query("SELECT * FROM $DB_IMAGE where collectionID=$cat $where ORDER BY $order_by limit $offset, $nb_per_page") or die(mysql_error()); while ($categ_list = mysql_fetch_array($select)) { // Lets show the images print ('<td align="center" valign="top"><img width="200" border="0" src="'.$image_folder.'/' . $categ_list[photo] .'"></td>'); if ($row == $col) { echo '</tr><tr>'; $row = 0; } $row++; } // Close the table echo "</table>"; $maxPage = ceil($nb_images / $nb_per_page); $self = "$mypage"; $nav = ''; for ($page = 1; $page <= $maxPage; $page++) { if ($page == $num_page) { $nav .= " $page "; } else { $nav .= " <a href=\"$self&page=$page\">$page</a> "; } } if ($num_page > 1) { $page = $num_page - 1; $prev = " <a href=\"$self&page=$page\">[Précédant]</a> "; $first = " <a href=\"$self&page=1\">[First page]</a> "; } else { $prev = ' '; $first = ' '; } if ($num_page < $maxPage) { $page = $num_page + 1; $next = " <a href=\"$self&page=$page\">[Next]</a> "; $last = " <a href=\"$self&page=$maxPage\">[Last page]</a> "; } else { $next = ' '; $last = ' '; } if ($re_page >= "$nb_images") { $re_page = "$nb_images"; } // Navigation print ("<center><br>($ree_page to $re_page from $nb_images) Page:<b>$first $prev $nav $next $last</center>"); ?> @Maq, It was only 1 line of code ... i use the [ code ] and [ php ] only when theres more then one line Quote Link to comment https://forums.phpfreaks.com/topic/226698-layout-view/#findComment-1169939 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.