473,325 Members | 2,671 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

paginationerror...image only in rows n not in columns

116 100+
i m trying to display the result images in table format or rows and columns but the cod i wrote displays them only in rows....someone plz help

Expand|Select|Wrap|Line Numbers
  1.  
  2. <?php
  3.  
  4. // generating a array with image paths
  5.  
  6. $query_images = "SELECT image_path,image_name FROM userfolders" ;
  7. $result_images = mysql_query($query_images);
  8. confirm_query($result_images);
  9.  
  10. while ($record_images = mysql_fetch_assoc($result_images)) {
  11.           $file = $record_images['image_name'] ;
  12.           $dirname = $record_images['image_path'] ;
  13.  
  14.  
  15. // generating a thumbnail
  16. $thumb_height = 100;
  17. $filename = $dirname."/".$file;
  18. $filename_array[] = $filename ;
  19. list($width, $height) = getimagesize($filename);
  20.         $ratio = ($height/$width);
  21.         $ratio_array[] = $ratio;
  22.         $newheight = $thumb_height;
  23.         $newheight_array[] = $newheight;
  24.         $newwidth = ($thumb_height/$ratio);
  25.         $newwidth_array[] = $newwidth;
  26.  
  27. $page = empty($_GET['page']) ? 1 : $_GET['page'];
  28. $num_per_page = 4;
  29. $total_pages = ceil(count($filename_array)/$num_per_page);
  30.  
  31. }
  32.  
  33. ?>
  34.  
  35. <?php
  36. for($i = ($page - 1) * $num_per_page; $i < $page * $num_per_page; $i++)
  37. {?><li><a href="<?php echo $filename_array[$i]; ?>">
  38. <img src="<?php echo $filename_array[$i]; ?>" width="<?php echo $newwidth_array[$i]; ?>" height="<?php echo $thumb_height_array[$i]; ?>" align="top"
  39. alt="<?php echo $filename_array[$i]; ?>" /></a></li>
  40. <?php
  41. }
  42. ?>
  43.  
  44. <?php
  45. echo "</ul>";
  46. $pages = array();
  47. for($i = 1; $i <= $total_pages; $i++) {
  48. $pages[] = "<a href=\"".$_SERVER['PHP_SELF']."?page=".$i."\">".$i."</a>";
  49. }
  50. echo "Page: ".implode(" ", $pages);
  51.  
  52. ?>
  53.  
Jun 24 '09 #1
2 1615
prabirchoudhury
162 100+
1. ok, you need make a table and run your forloop inside that table
2. when you run for loop then after a selected no of <td> you need to make a new <tr> to make another row.

3. we geting all say 100 images in one row. how can we make it so that every 10th (could change this no, you want) image ends the row, and starts a new one? could use the Modulus arithmetic operand to calculate that. The operand sign is the percent sign (%). So you set up our if() statement thusly:


Expand|Select|Wrap|Line Numbers
  1.  
  2. <table align=center border=0 >
  3. <tbody>
  4. <tr>
  5. for ($i=1; $i<= $total_pages; $i++)
  6. {
  7.  
  8. $pages = "<a href=\"".$_SERVER['PHP_SELF']."?page=".$i."\">".$i."</a>";
  9.   echo('<TD align=top>');
  10.   echo $pages; 
  11.   echo('</TD>');
  12.   if($i % 10 == 0)
  13.         {
  14.           echo '</tr>
  15.           <tr>';
  16.         }
  17.  
  18. }
  19.  
  20. </TBODY>
  21. </TABLE>
  22.  
  23.  
:))
Jun 25 '09 #2
angelicdevil
116 100+
well i did wat u told me its still not working.

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. // generating a array with image paths
  4.  
  5. $query_images = "SELECT image_path,image_name FROM userfolders" ;
  6. $result_images = mysql_query($query_images);
  7. confirm_query($result_images);
  8.  
  9. while ($record_images = mysql_fetch_assoc($result_images)) {
  10.           $file = $record_images['image_name'] ;
  11.           $dirname = $record_images['image_path'] ;
  12.  
  13.  
  14. // generating a thumbnail
  15. $thumb_height = 100;
  16. $filename = $dirname."/".$file;
  17. $filename_array[] = $filename ;
  18. list($width, $height) = getimagesize($filename);
  19.         $ratio = ($height/$width);
  20.         $ratio_array[] = $ratio;
  21.         $newheight = $thumb_height;
  22.         $newheight_array[] = $newheight;
  23.         $newwidth = ($thumb_height/$ratio);
  24.         $newwidth_array[] = $newwidth;
  25.  
  26. $page = empty($_GET['page']) ? 1 : $_GET['page'];
  27. $num_per_page = 4;
  28. $total_pages = ceil(count($filename_array)/$num_per_page);
  29.  
  30. }
  31.  
  32. ?>
  33.  
  34. <?php
  35. for($i = ($page - 1) * $num_per_page; $i < $page * $num_per_page; $i++)
  36. {?><li><a href="<?php echo $filename_array[$i]; ?>">
  37. <img src="<?php echo $filename_array[$i]; ?>" width="<?php echo $newwidth_array[$i]; ?>" height="<?php echo $thumb_height_array[$i]; ?>" align="top"
  38. alt="<?php echo $filename_array[$i]; ?>" /></a></li>
  39. <?php
  40. }
  41. ?>
  42.  
  43.  
  44.  
  45.  
  46.  
  47. <?php
  48. echo "</ul>";
  49. $pages = array();
  50. ?>
  51. <table align=center border=0 >
  52. <tbody>
  53. <tr>
  54. <?php
  55.  
  56. for ($i=1; $i<= $total_pages; $i++)
  57. {
  58.  
  59. $pages = "<a href=\"".$_SERVER['PHP_SELF']."?page=".$i."\">".$i."</a>";
  60.   echo('<TD align=top>');
  61.   echo $pages; 
  62.   echo('</TD>');
  63.   if($i % 10 == 0)
  64.         {
  65.           echo '</tr>
  66.           <tr>';
  67.         }
  68.  
  69. }
  70. ?>
  71.  
  72. </TBODY>
  73. </TABLE>
  74.  
  75.  
Jul 14 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Doug van Vianen | last post by:
Although I have programmed for several decades I am new to Java. I decided to learn it to create Applets to use in web pages I make as a volunteer in the computer club at a seniors' centre. My...
8
by: Jef Driesen | last post by:
I'm implementing some image processing algorithms in C++. I created a class called 'image' (see declaration below), that will take care of the memory allocations and some basic (mathematical)...
6
by: QuasiChameleon | last post by:
Hi, I'm trying to create a grayscale image class that reads and writes grayscale Targa format. This works well with smaller images, but corrupts larger images and creates a "Segmentation fault...
0
by: Anonieko Ramos | last post by:
> I have a graphics images that I want to convert to > ASCII art. How do I do it? > Code: - Default.aspx.cs
1
by: John Thompson | last post by:
We're sooo close. When we load the page to upload the image, all of the prms go through except the binary image data. Using SQL server with the data type set to "image". Please help! Thanks-...
2
by: dineshbajaj | last post by:
Hi Everybody, I need to split an image file(*.jpeg) programmatically to nine or more equal parts. Since, the code is meant to run on Windows Pocket PC 2002, I can only use methods supported...
10
by: Enrique Cruiz | last post by:
Hello all, I am currently implementing a fairly simple algorithm. It scans a grayscale image, and computes a pixel's new value as a function of its original value. Two passes are made, first...
1
by: tuman | last post by:
I am making a project which is related to classified web site. I have used a gridview control. In which put some sqltable data. And i want to show a image which is store in my project folder,...
0
by: harshad | last post by:
Dear All,Here I am facing problem to store image.I am trying to store byte array(image) in to session variable so at time of update I will got that byte array and I do my update. here i am given...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.