Jump to content

jebsays

New Members
  • Posts

    1
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

jebsays's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Was wondering if anyone may be able to help with a PHP paging issue? What I'm ultimately trying to do is very similar to the Coppermine photo gallery or Tiffany website... Basically, a table that displays an item image in the top left cell, item data across the right column cell... and then on the bottom, I want it to display the thumbnails for the first 3 results. Here is the code that I am using : [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]<? require "config123.php"; // Database connection details $page_name="php_paging2.php"; // Document name if(!isset($start)) { // This variable is set to zero for the first page $start = 0; } $eu = ($start -0); $limit = 1; // No of records to be shown per page. $this = $eu + $limit; $back = $eu - $limit; $next = $eu + $limit; /////////////// WE have to find out the number of records in our table. We will use this to break the pages/////// $query2=" SELECT * FROM art WHERE Size ='Small' "; $result2=mysql_query($query2); echo mysql_error(); $nume=mysql_num_rows($result2); /////// The variable nume above will store the total number of records in the table//// ////////////// Now let us start executing the query with variables $eu and $limit set at the top of the page/////////// $query=" SELECT * FROM art Where Size ='Small' limit $eu, $limit "; $result=mysql_query($query); echo mysql_error(); //////////////// Now we will display the returned records in side the rows of the table///////// while($noticia = mysql_fetch_array($result)) { if($bgcolor=='#f1f1f1'){$bgcolor='#ffffff';} else{$bgcolor='#f1f1f1';} echo "<table width='590' border='5' cellpadding='2'><tr>"; echo "<td colspan='2' rowspan='7' align='center' valign='middle'><img src=\"$noticia[Thumbnail]\"></td>"; echo "<td height='57' valign='bottom'>Enlarged view</td></tr>"; echo "<tr><td width='181' height='57'>$noticia[Title]</td></tr>"; echo "<tr><td height='34' valign='top'>$noticia[Dimensions]</td></tr>"; echo "<tr><td height='33' valign='top'>$noticia[Medium]</td></tr>"; echo "<tr><td height'34' valign='top'>$$noticia[Price]</td></tr>"; echo "<tr><td height='51' align='right' valign='bottom'>Page 1 of whatever | 1-2-3- </td> </tr>"; echo "<tr> <td height='30'>&nbsp;</td> </tr>"; echo "<tr><td width='134' height='21' valign='top'><img src=\"$noticia[Thumbnail]\"></td>"; echo "<td width='191' valign='top'><img src=\"$noticia[Thumbnail]\"></td>"; echo "<td height='21' valign='top'><img src=\"$noticia[Thumbnail]\"></td></tr></table>"; ////////////////////////////// End of displaying the table with records //////////////////////// ///// Variables set for advance paging/////////// $p_limit=5; // This should be more than $limit and set to a value for whick links to be breaked if(!isset($p_f)){$p_f=0;} $p_fwd=$p_f+$p_limit; $p_back=$p_f-$p_limit; //////////// End of variables for advance paging /////////////// /////////////// Start the buttom links with Prev and next link with page numbers ///////////////// echo "<table align = 'center' width='50%'><tr><td align='left' width='20%'>"; if($p_f<>0){print "<a href='$page_name?start=$p_back&p_f=$p_back'><font face='Verdana' size='2'>PREV $p_limit</font></a>"; } echo "</td><td align='left' width='10%'>"; //// if our variable $back is equal to 0 or more then only we will display the link to move back //////// if($back >=0 and ($back >=$p_f)) { print "<a href='$page_name?start=$back&p_f=$p_f'><font face='Verdana' size='2'>PREV</font></a>"; } //////////////// Let us display the page links at center. We will not display the current page as a link /////////// echo "</td><td align=center width='30%'>"; for($i=$p_f;$i < $nume and $i<($p_f+$p_limit);$i=$i+$limit){ if($i <> $eu){ $i2=$i+$p_f; echo " <a href='$page_name?start=$i&p_f=$p_f'><font face='Verdana' size='2'>$i</font></a> "; } else { echo "<font face='Verdana' size='4' color=red>$i</font>";} /// Current page is not displayed as link and given font color red } } echo "</td><td align='right' width='10%'>"; ///////////// If we are not in the last page then Next link will be displayed. Here we check that ///// if($this < $nume and $this <($p_f+$p_limit)) { print "<a href='$page_name?start=$next&p_f=$p_f'><font face='Verdana' size='2'>NEXT</font></a>";} echo "</td><td align='right' width='20%'>"; if($p_fwd < $nume){ print "<a href='$page_name?start=$p_fwd&p_f=$p_fwd'><font face='Verdana' size='2'>NEXT $p_limit</font></a>"; } echo "</td></tr></table>"; ?>[/quote] you can see the results of this script at [a href=\"http://joyceabbe.com/php_paging2.php\" target=\"_blank\"]this link[/a]. Whenever I set the results to higher than 1 per page, it replicates the table once for each row of data queried... Does anyone know how I can modify the code so that I can display the proper thumbnails in the 2rd and 3rd positions across? Ultimately, I want to make each thumbnail a link that loads the products data and image into the main data display of the table... while maintaining the pagination. Thanks for any help that you can provide. JB
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.