Problem displaying SQL result

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
neugent
Forum Newbie
Posts: 24
Joined: Wed Jul 06, 2005 3:35 am
Location: Philippines

Problem displaying SQL result

Post by neugent »

Can anyone help me? Im still a beginner with PHP and MySQL.

If for example i have a field item_code and item_desc in my table, and i wanted to display my data in a HTML table like below:

Code: Select all

Html Output:

CODE:      CODE:       CODE:
VC-A-BR1   VC-A-BR2    VC-A-E1
DESC:      DESC:       DESC:
Bracelet   Bracelet    Earring

CODE:      CODE:       CODE:
VC-A-E2    VC-A-N1     VC-A-N2
DESC:      DESC:       DESC:
Earring    Necklace    Necklace

CODE:      CODE:       CODE:
VC-B-BR1   VC-B-BR2    VC-B-E1
DESC:      DESC:       DESC:
Bracelet   Bracelet    Earring
..and so on...

How can i do that?
Thank you very much.
User avatar
harrisonad
Forum Contributor
Posts: 288
Joined: Fri Oct 15, 2004 4:58 am
Location: Philippines
Contact:

Post by harrisonad »

Code: Select all

$str = "
<table>
<tr>";
$count = 0;
while($data = mysql_fetch_array($result)){
	$count++;
	$code = $data['item_code'];
	$desc = $data['item_desc'];
	$str .= "
	<td>Code: $code<br>
		Desc: $desc</td>";
	if($count==3){
		$str .= "
               </tr>
               &;";
$count = 0;
while($data = mysql_fetch_array($result)){
	$count++;
	$code = $data['item_code'];
	$desc = $data['item_desc'];
	$str .= "
	<td>Code: $code<br>
		Desc: $desc</td>";
	if($count==3){
		$str .= "
               </tr>
               <tr>&qgt;Code: $code<br>
		Desc: $desc</td>";
	if($count==3){
		$str .= "
               &am = mysql_fetch_array($result)){
	$count++;
	$code = $data['item_code'];
	$desc = $data['item_desc'];
	$str .= "
	<td>Code: $code<br>
		Desc: $desc</td>";
	if($count==3){
		$str .= "
               </tr>le>
<tr>";
$count = 0;
while($data = mysql_fetch_array($result)){
	$count++;
	$code = $data['item_code'];
	$desc = $data['item_desc'];
	$str .= "
	<td>Code: $code<br>
$str = "
<table>
<tr>";
$count = 0;
while($data = mysql_fetch_array($result)){
	$count++;
	$code = $data['item_code'];
	$desc = $data['item_desc'];
	$str .= "
	<td>Code: $code<br>
		Desc: $desc</td&g
$str = "
<table>
<tr>";
$count = 0;
while($data = mysql_fetch_array($result)){
	$count++;
	$code = $data['item_code'];
	$desc = $data['item_desc'];
	$str .= "
	<td>Code: $code<br>
		Desc: $desc</td>";
	if($count==3){
		$str .= "
    
$count = 0;
while($data = mysql_fetch_array($result)){
	$count++;
	$code = $data['item_code'];
	$desc = $data['item_desc'];
	$str .= "
	<td>Code: $code<br>
		Desc: $desc</td>";
	if($count==3){
		$str .= "
               </tr>
               <tr>":
		$count = 0;
	}
}
$str .= "
</table>";

echo $str;
= mysql_fetch_array($result)){
$count++;
$code = $dataї'item_code'];
$desc = $dataї'item_desc'];
$str .= "
<td>Code: $code<br>
Desc: $desc</td>";
if($count==3){
$str .= "
</tre;
<table>
<tr>";
$count = 0;
while($data = mysql_fetch_array($result)){
$count++;
$code = $dataї'item_code'];
$desc = $data['item_desc'];
$str .= "
<td>Code: $code<br>
Desc: $desc&lt;/td&gt;&quote;;
if($count==3){
$str .= "
</tr>
<tr&gt;&quote;:
$count = 0;
}
}
$str .= &quote;
</table>";

echo $str;
amp;lt;/td>";
if($count==3){
$str .= "
</tr>
<tr>":
$count = 0;
}
}
$str .= "
</table>";

echo $str;
;amp;gt;
<tr>";
$count = 0;
while($data = mysql_fetch_array($result)){
$count++;
$code = $dataї'item_code'];
$desc = $dataї'item_desc'];
$str .= &quote;
&lt;td&gt;Code: $code&lt;br&gt;
Desc: $desc&lt;/td&gt;&quote;;
if($count==3){
$str .= &quote;
&lt;/tr&gt;
&lt;tr&gt;&quote;:
$count = 0;
}
}
$str .= &quote;
&lt;/table&gt;&quote;;

echo $str;
gt;
Desc: $desc</td>";
if($count==3){
$str .= "
</tr>
<tr>":
$count = 0;
}
}
$str .= "
</table>";

echo $str;
($result)){
$count++;
$code = $data['item_code'];
$desc = $data['item_desc'];
$str .= "
&lt;td&gt;Code: $code&lt;br&gt;
Desc: $desc&lt;/td&gt;&quote;;
if($count==3){
$str .= &quote;
&lt;/ttr>";
$count = 0;
while($data = mysql_fetch_array($result)){
$count++;
$code = $dataї'item_code'];
$desc = $dataї'item_desc'];
$str .= &quote;
&lt;td&gt;Code: $code&lt;br&gt;
Desc: $desc&lt;/td&gt;&quote;;
if($count==3){
$str .= &quote;
&lt;/tr&gt;
&lt;tr&
$str = "
<table>
<tr>";
$count = 0;
while($data = mysql_fetch_array($result)){
$count++;
$code = $data['item_code'];
$desc = $data['item_desc'];
$str .= "
<td>Code: $code<br>
Desc: $desc</td>";
if($count==3){
$str .= "
</tr>
<tr>":
$count = 0;
}
}
$str .= "
</table>";

echo $str;
p;amp;lt;tr>";
$count = 0;
while($data = mysql_fetch_array($result)){
$count++;
$code = $data['item_code'];
$desc = $data['item_desc'];
$str .= &quote;
&lt;td&gt;Code: $code&lt;br&gt;
Desc: $desc&lt;/td&gt;&quote;;
if($count==3){
$str .= &quote;
&lt;/tr&gt;
&lt;tr&gt;&quote;:
$count = 0;
}
}
$str .= &quote;
&lt;/table&gt;&quote;;

echoc = $data['item_desc'];
$str .= "
<td>Code: $code<br>
Desc: $desc</td>";
if($count==3){
$str .= "
</tr>
<tr>":
$count = 0;
}
}
$str .= "
</table>";

echo $str;

$str = "
<table>
<tr>";
$count = 0;
while($data = mysql_fetch_array($result)){
$count++;
$code = $data['item_code'];
$desc = $data['item_desc'];
$str .= "
<td>Code: $code<br>
Desc: $desc&lt;/td&gt;&quote;;
if($count==3){
$str .= &quote;
&lt;/tr&gt;
&lt;tr&gt;&quote;:
$count = 0;
}
}
$str .= &quote;
&lt;/table&gt;&quote;;

echo $str;
p;lt;table>
<tr>";
$count = 0;
while($data = mysql_fetch_array($result)){
$count++;
$code = $data['item_code'];
$desc = $dataї'item_desc'];
$str .= &quote;
&lt;td&gt;Code: $code&lt;br&gt;
Desc: $desc&lt;/td&gt;&quote;;
if($count==3){
$str .= &quote;
&lt;/tr&gt;
&lt;tr&gt;&quote;:
$count =$count = 0;
while($data = mysql_fetch_array($result)){
$count++;
$code = $dataї'item_code'];
$desc = $data['item_desc'];
$str .= &quote;
&lt;td&gt;Code: $code&lt;br&gt;
Desc: $desc&lt;/td&gt;&quote;;
if($count==3){
$str .= &quote;
&lt;/tr&gt;
&lt;tr&gt;&quote;:
;
while($data = mysql_fetch_array($result)){
$count++;
$code = $dataї'item_code'];
$desc = $data['item_desc'];
$str .= "
<td>Code: $code<br>

$str = "
<table>
<tr>";
$count = 0;
while($data = mysql_fetch_array($result)){
$count++;
$code = $data['item_code'];
$desc = $data['item_desc'];
$str .= &quote;
&lt;td&gt;Code: $code&lt;br&gt;
Desc: $desc&lt;/td&gt;&quote;;
if($count==3){
$str .= &quote;
&lt;/tr&gt;
&lt;tr&gt;&quote;:
$count = 0;
sult)){
$count++;
$code = $data['item_code'];
$desc = $data['item_desc'];
$str .= "
<td>Code: $code<br>
Desc: $desc</td>";
if($count==3){
$str .= "
</tr>
<tr>":
$count = 0;
}
}
$str .= "
</table>";

echo $str;
mp;quote;
<td>Code: $code<br>
Desc: $desc</td>";
if($count==3){
$str .= "
</tr>
<tr&gt;&quote;:
$count = 0;
}
}
$str .== "
</tr>
<tr>":
$count = 0;
}
}
$str .= "
</table>";

echo $str;
[/php:1p;amp;gt;
<tr>";
$count = 0;
while($data = mysql_fetch_array($result)){
$count++;
$code = $data['item_code'];
$desc = $data['item_desc'];
$str .= "
<td>Code: $code<br>
Desc: $desc</td>";
if($count==3){
$str .= "
</tr>
<tr>":
$count = 0;
}
}
$str .= "
</table>";

echo $str;
1;'item_desc'];
$str .= "
<td&gt;Code: $code&lt;br&gt;
Desc: $desc&lt;/td&gt;&quote;;
if($count==3){
$slt;table>
<tr>";
$count = 0;
while($data = mysql_fetch_array($result)){
$count++;
$code = $data['item_code'];
$desc = $data['item_desc'];
$str .= "
<td>Code: $code<br>
Desc: $desc</td>";
if($count==3){
$str .= "
</tr>
<tr>":
$count = 0;
}
}
$str .= "
</table>";

echo $str;
sql_fetch_array($result)){
$count++;
$code = $dataї'item_code'];
$desc = $dataї'item_desc'];
$str .= &quote;
&lt;td&gt;Code: $code&lt;br&gt;
Desc: $desc&lt;/td&gt;&quote;;
if($count==3){
$str .= &quote;
&lt;/tr&gt;
&lt;tr&gt;&ampmp;lt;table>
<tr>";
$count = 0;
while($data = mysql_fetch_array($result)){
$count++;
$code = $data['item_code'];
$desc = $data['item_desc'];
$str .= "
<td>Code: $code<br>
Desc: $desc</td>";
if($count==3){
$str .= "
</tr>
<tr>":
$count = 0;
}
}
$str .= "
</table>";

echo $str;

$str = "
<table>
<tr>";
$count = 0;
while($data = mysql_fetch_array($result)){
$count++;
$code = $data['item_code'];
$desc = $data['item_desc'];
$str .= "
<td>Code: $code<br>
Desc: $desc</td>";
if($count==3){
$str .= "
</tr>
<tr>":
$count = 0;
}
}
$str .= "
</table>";

echo $str;
neugent
Forum Newbie
Posts: 24
Joined: Wed Jul 06, 2005 3:35 am
Location: Philippines

Post by neugent »

Thank you very much. I've got it running, compared to my code, yours is a lot more easier and efficient. Im going to play around with it.

Thanks again. :D
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

1 thing you forgot is about is if the amount of rows is not a multiple of 3, then your going to have an invalid table -- if that means anything to you. What you should do is check if the loop is in the last iteration, then do the amount of total rows % 3 which will give you the remainder, and enter a new loop that many times filling in the missing columns.
User avatar
harrisonad
Forum Contributor
Posts: 288
Joined: Fri Oct 15, 2004 4:58 am
Location: Philippines
Contact:

Post by harrisonad »

yeah, that's true. I have to insert this to fill remaining <TD>'s

Code: Select all

if($count){
   foreach($x=($count+1);$x<3;$x++){
      $str .= "<td>&nbsp</td>";
   }
}
$str .= "
</tr>
</table>";
Thanks for noticing my mistake, jcartd>&nbsp</td>";
}
}
$str .= "
</tr>
</table>";

Thanks for noticing my mistake, jcart<TD>'s

Code: Select all

if($count){
   foreach($x=($count+1);$x<3;$x++){
      $str .= "<td>&nbsp</td>";
   }
}
$str .= "
</tr>
</table>";
Thanks for noticing my mistake, jcart;3;$x++){
$str .= "<td&gt;&amp;nbsp&lt;/td&gt;&quote;;
}
}
g <TD>'s

Code: Select all

if($count){
   foreach($x=($count+1);$x<3;$x++){
      $str .= "<td>&nbsp</td>";
   }
}
$str .= "
</tr>
</table>";
Thanks for noticing my mistake, jcartount+1);$x<3;$x++){
$str .= "<td>&nbsp</td>";
}
}
$str .= &quotamp;lt;3;$x++){
$str .= "<td>&nbsp</td>";
}
}
$str .= "
&am I have to insert this to fill remaining <TD>'s

Code: Select all

if($count){
   foreach($x=($count+1);$x<3;$x++){
      $str .= "<td>&nbsp</td>";
   }
}
$str .= "
</tr>
</table>";
Thanks for noticing my mistake, jcart this to fill remaining <TD>'s

Code: Select all

if($count){
   foreach($x=($count+1);$x<3;$x++){
      $str .= "<td>&nbsp</td>";
   }
}
$str .= "
</tr>
</table>";
Thanks for noticing my mistake, jcartgt;";
}
}
$str .= "
</tr>
</table>";

Thanks for noticing my mistake, jcartp;amp;nbsp</td>";
}
}
$str .= "
</tr>
</table>";

Thanks for noticing my mistake, jcartgt;'s

Code: Select all

if($count){
   foreach($x=($count+1);$x<3;$x++){
      $str .= "<td>&nbsp</td>";
   }
}
$str .= "
</tr>
</table>";
Thanks for noticing my mistake, jcartote;;
}
}
$str .= "
</tr>
</table>";

Thanks for noticing my mistake, jcart($count){
foreach($x=($count+1);$x<3;$x++){
$str .= "<td>&nbsp& I have to insert this to fill remaining <TD>'s

Code: Select all

if($count){
   foreach($x=($count+1);$x<3;$x++){
      $str .= "<td>&nbsp</td>";
   }
}
$str .= "
</tr>
</table>";
Thanks for noticing my mistake, jcart to fill remaining <TD>'s

Code: Select all

if($count){
   foreach($x=($count+1);$x<3;$x++){
      $str .= "<td>&nbsp</td>";
   }
}
$str .= "
</tr>
</table>";
Thanks for noticing my mistake, jcartamp;nbsp</td>";
}
}
$str .= &quote;
&lt;/tr>
</table>";

Thanks for noticing my mistake, jcartll remaining <TD>'s

Code: Select all

if($count){
   foreach($x=($count+1);$x<3;$x++){
      $str .= "<td>&nbsp</td>";
   }
}
$str .= "
</tr>
</table>";
Thanks for noticing my mistake, jcart</table>";

Thanks for noticing my mistake, jcartTD>'s

Code: Select all

if($count){
   foreach($x=($count+1);$x<3;$x++){
      $str .= "<td>&nbsp</td>";
   }
}
$str .= "
</tr>
</table&ampx=($count+1);$x<3;$x++){
      $str .= "<td>&nbsp</td>";
   }
}
$str .= "
</tr>
</table>";
Thanks for noticing my mistake, jcart I have to insert this to fill remaining <TD>'s

Code: Select all

if($count){
   foreach($x=($count+1);$x<3;$x++){
      $str .= "<td>&nbsp</td>";
   }
}
$str .= "
</tr>
</table>";
[/php:1:ce009842
if($count){
   foreach($x=($count+1);$x<3;$x++){
      $str .= "<td>&nbsp</td>";
   }
}
$str .= "
</tr>
</table>";
Thanks for noticing my mistake, jcart
neugent
Forum Newbie
Posts: 24
Joined: Wed Jul 06, 2005 3:35 am
Location: Philippines

Post by neugent »

Ive added that last part already on my script and also added page numbers where it'll limit at 15 results. thank you guys for the additional infos.
neugent
Forum Newbie
Posts: 24
Joined: Wed Jul 06, 2005 3:35 am
Location: Philippines

Post by neugent »

I think its FOR right? you posted FOREACH. :)

Code: Select all

<?php
if($count){
   for($x=($count+1);$x<3;$x++){
      $str .= "<td>&nbsp</td>";
   }
}
$str .= "
</tr>
</table>";
p;amp;nbsp</td>";
}
}
$str .= "
</tr>
</table>";81b0ea3]<?php
if($count){
for($x=($count+1);$x<3;$x++){
$str .= "<td>&nbsp</td>";
}
}
$str .= "
</tr>
</table>";r .= "<td>&nbsp&amp6681b0ea3]<?php
if($count){
for($x=($count+1);$x<3;$x++){
$str .= "<td>&nbsp</td>";
}
}
$str .= "
</tr>
</table>";t;3;$x++){
$str .= "<td>&nbsp</td>";
}
}
$str .= "
</tr&
$str .= "<td>&nbsp</td>";
}
}
$str .= "
</tr&ampght? you posted FOREACH. :)

Code: Select all

<?php
if($count){
   for($x=($count+1);$x<3;$x++){
      $str .= "<td>&nbsp</td>";
   }
}
$str .= "
</tr>
</table>";
OREACH. :)

Code: Select all

<?php
if($count){
   for($x=($count+1);$x<3;$x++){
      $str .= "<td>&nbsp</td>";
   }
}
$str .= "
</tr>
</table>";
}
}
$str .= "
</tr>
</table>";t;/td>";
}
}
$str .= "
</tr>
</table>";p;lt;?php
if($count){
for($x=($count+1);$x<3;$x++){
$str .= "<td>&nbsp</td>";
}
}
$str .= "
</tr>
</table>"; .= "
</tr>
</table>";r($x=($count+1);$x<3;$x++){
$str .= "<td>&nbsp</td>&aght? you posted FOREACH. :)

Code: Select all

<?php
if($count){
   for($x=($count+1);$x<3;$x++){
      $str .= "<td>&nbsp</td>";
   }
}
$str .= "
</tr>
</table>";
H. :)

Code: Select all

<?php
if($count){
   for($x=($count+1);$x<3;$x++){
      $str .= "<td>&nbsp</td>";
   }
}
$str .= "
</tr>
</table>";
;amp;lt;/td>";
}
}
$str .= "
</tr&gt;
&lt;/table>";

Code: Select all

<?php
if($count){
   for($x=($count+1);$x<3;$x++){
      $str .= "<td>&nbsp</td>";
   }
}
$str .= "
</tr>
</table>";
mp;amp;gt;";<?php
if($count){
for($x=($count+1);$x<3;$x++){
$str .= "<td>&nbsp</td>";
}
}
$str .= "
</tr>
</table>";
User avatar
harrisonad
Forum Contributor
Posts: 288
Joined: Fri Oct 15, 2004 4:58 am
Location: Philippines
Contact:

Post by harrisonad »

oops! :oops: sorry. you got it right.
I think i have to wear glasses from now on. 8O
neugent
Forum Newbie
Posts: 24
Joined: Wed Jul 06, 2005 3:35 am
Location: Philippines

Post by neugent »

Here's my code with the pages, results per query is limited to 15 rows.
If you have a much better way, please do suggest.

The only problem is that if the last pages has only 1 result to display, i have this HTML fragment <tr></tr>, the rest its ok. Just notice this though. :)

Code: Select all

<?php 
require("config.php");
require("conn.php");
$thumbs = $config['imagethumb'];
$limits = 15;
$start = 0;

$pagerequest = $_REQUEST['id'];

if ($pagerequest>1){
	$start = (($pagerequest -1)* $limits);
	$sql = "select item_code from items LIMIT $start, $limits";
} else{
	$sql = "select item_code from items LIMIT $start, $limits";
}

$sqlcount ="select item_code from items";
$result = mysql_query($sql) or die("Login Query Failed." . mysql_error() . " ". $sql);
$sqlcountresult = mysql_query($sqlcount) or die("Login Query Failed." . mysql_error() . " ". $sql);
$num_rows = mysql_num_rows($sqlcountresult);

$getpages = ceil($num_rows / 15);

echo	"Found $num_rows Rows.<br>
		There are $getpages pages";


$str = 	"
		<table cellpadding=10>
		<tr>";
		
$count = 0;
while($data = mysql_fetch_array($result)){
    $count++;
    $code = $data['item_code'];
    $desc = $data['item_desc'];
    $str .= "
    <td class='tdfonts'>
	<div align='center'>
		<img src='$thumbs$code.jpg' border='1' class='imgborder' hspace='5' vspace=' have this HTML fragment <tr></tr>, the rest its ok. Just notice this though.

Code: Select all

<?php 
require("config.php");
require("conn.php");
$thumbs = $config['imagethumb'];
$limits = 15;
$start = 0;

$pagerequest = $_REQUEST['id'];

if ($pagerequest>1){
	$start = (($pagerequest -1)* $limits);
	$sql = "select item_code from items LIMIT $start, $limits";
} else{
	$sql = "select item_code from items LIMIT $start, $limits&quote;;
}

$sqlcount =&quote;select item_code from items&quote;;
$result = mysql_query($sql) or die(&quote;Login Query Failed.&quote; . mysql_error() . &quote; &quote;. $sql);
$sqlcountresult = mysql_query($sqlcount) or die(&quote;Login Query Failed.&quote; . mysql_error() . &quote; &quote;. $sql);
$num_rows = mysql_num_rows($sqlcountresult);

$getpages = ceil($num_rows / 15);

echo	&quote;Found $num_rows Rows.&lt;br&gt;
		There are $getpages pages&quote;;


$str = 	&quote;
		&lt;table cellpadding=10&gt;
		&lt;tr&gt;&quote;;
		
$count = 0;
while($data = mysql_fetch_array($result)){
    $count++;
    $code = $data&#1111;'item_code'];
    $desc = $data&#1111;'item_desc'];
    $str .= &quote;
    &lt;td class='tdfonts'&gt;
	&lt;div align='center'&gt;
		&lt;img src='$thumbs$code.jpg' border='1' class='imgborder' hspace='5' vspace='5'&gt;&lt;br&gt;
		&lt;b&gt;Code:&lt;/b&gt; $code&lt;br&gt;
        &lt;b&gt;Desc:&lt;/b&gt; $desc
	&lt;/div&gt;
	&lt;/td&gt;&quote;;
    if($count==3){
        $str .= &quote;
               &lt;/tr&gt;
               &lt;tr&gt;&quote;;
        $count = 0;
    }
	
}
if($count){
	   	for($x=($count+1); $x&lt;3; $x++){
    	  $str .= &quote;&lt;td&gt;&amp;nbsp&lt;/td&gt;&quote;;
   		}
	}

$str .= &quote;
		&lt;/tr&gt;
		&lt;/table&gt;&quote;;
 
echo $str;

for($z=1; $z&lt;=$getpages; $z++){
	echo &quote;&lt;a href='$PHP_SELF?id=$z'&gt;$z&lt;/a&gt;&amp;nbsp;&quote;;
}
?&gt;[/php:1imits";
}

$sqlcount ="select item_code from items";
$result = mysql_query($sql) or die(&quote;Login Query Failed.&quote; . mysql_error() . &quote; &quote;. $sql);
$sqlcountresult = mysql_query($sqlcount) or die(&quote;Login Query Failed." . mysql_error() . " ". $sql);
$num_rows = mysql_num_rows($sqlcountresult);

$getpages = ceil($num_rows / 15);

echo	"Found $num_rows Rows.&lt;br&gt;
		There are $getpages pages&quote;;


$str = 	&quote;
		&lt;table cellpadding=10&gt;
		&lt;tr&gt;&quote;;
		
$count = 0;
while($data = mysql_fetch_array($result)){
    $count++;
    $code = $data&#1111;'item_code'];
    $desc = $data&#1 to 15 rows.
If you have a much better way, please do suggest. 

The only problem is that if the last pages has only 1 result to display, i have this HTML fragment <tr></tr>, the rest its ok. Just notice this though.

Code: Select all

<?php 
require("config.php");
require("conn.php");
$thumbs = $config['imagethumb'];
$limits = 15;
$start = 0;

$pagerequest = $_REQUEST['id'];

if ($pagerequest>1){
	$start = (($pagerequest -1)* $limits);
	$sql = &quote;select item_code from items LIMIT $start, $limits&quote;;
} else{
	$sql = &quote;select item_code from items LIMIT $start, $limits&quote;;
}

$sqlcount =&quote;select item_code from items&quote;;
$result = mysql_query($sql) or die(&quote;Login Query Failed.&quote; . mysql_error() . &quote; &quote;. $sql);
$sqlcountresult = mysql_query($sqlcount) or die(&quote;Login Query Failed.&quote; . mysql_error() . &quote; &quote;. $sql);
$num_rows = mysql_num_rows($sqlcountresult);

$getpages = ceil($num_rows / 15);

echo	&quote;Found $num_rows Rows.&lt;br&gt;
		There are $getpages pages&quote;;


$str = 	&quote;
		&lt;table cellpadding=10&gt;
		&lt;tr&gt;&quote;;
		
$count = 0;
while($data = mysql_fetch_array($result)){
    $count++;
    $code = $data&#1111;'item_code'];
    $desc = $data&#1111;'item_desc'];
    $str .= &quote;
    &lt;td class='tdfonts'&gt;
	&lt;div align='center'&gt;
		&lt;img src='$thumbs$code.jpg' border='1' class='imgborder' hspace='5' vspace='5'&gt;&lt;br&gt;
		&lt;b&gt;Code:&lt;/b&gt; $code&lt;br&gt;
        &lt;b&gt;Desc:&lt;/b&gt; $desc
	&lt;/div&gt;
	&lt;/td&gt;&quote;;
    if($count==3){
        $str .= &quote;
               &lt;/tr&gt;
               &lt;tr&gt;&quote;;
        $count = 0;
    }
	
}
if($count){
	   	for($x=($count+1); $x&aif the last pages has only 1 result to display, i have this HTML fragment <tr></tr>, the rest its ok. Just notice this though.

Code: Select all

&lt;?php 
require(&quote;config.php&quote;);
require(&quote;conn.php&quote;);
$thumbs = $config&#1111;'imagethumb'];
$limits = 15;
$start = 0;

$pagerequest = $_REQUEST&#1111;'id'];

if ($pagerequest&gt;1){
	$start = (($pagerequest -1)* $limits);
	$sql = &quote;select item_code from items LIMIT $start, $limits&quote;;
} else{
	$sql = &quote;select item_code from items LIMIT $start, $limits&quote;;
}

$sqlcount =&quote;select item_code from items&quote;;
$result = mysql_query($sql) or die(&quote;Login Query Failed.&quote; . mysql_error() . &quote; &quote;. $sql);
$sqlcountresult = mysql_query($sqlcount) or die(&quote;Login Query Failed.&quote; . mysql_error() . &quote; &quote;. $sql);
$num_rows = mysql_num_rows($sqlcountresult);

$getpages = ceil($num_rows / 15);

echo	&quote;Found $num_rows Rows.&lt;br&gt;
		There are $getpages pages&quote;;


$str = 	&quote;
		&lt;table cellpadding=10&gt;
		&lt;tr&gt;&quote;;
		
$count = 0;
while($data = mysql_fetch_array($result)){
    $count++;
    $code = $data&#1111;'item_code'];
    $desc = $data&#1111;'item_desc'];
    $str .= &quote;
    &lt;td class='tdfonts'&gt;
	&lt;div align='center'&gt;
		&lt;img src='$thumbs$code.jpg' border='1' class='imgborder' hspace='5' vspace='5'&gt;&lt;br&gt;
		&lt;b&gt;Code:&lt;/b&gt; $code&lt;br&gt;
        &lt;b&gt;Desc:&lt;/b&gt; $desc
	&lt;/div&gt;
	&lt;/td&gt;&quote;;
    if($count==3){
        $str .= &quote;
               &lt;/tr&gt;
               &lt;tr&gt;&quote;;
        $count = 0;
    }
	
}
if($count){
	   	for($x=($count+1); $x&lt;3; $x++){
    	  $str .= &quote;&lt;td&gt;&amp;nbsp&lt;/td&gt;&quote;;
   		}
	}

$str .= &quote;
		&lt;/tr&gt;
		&lt;/table&gt;&quote;;
 
echo $str;

for($z=1; $z&lt;=$getpages; $z++){
	echo &ed to 15 rows.
If you have a much better way, please do suggest. 

The only problem is that if the last pages has only 1 result to display, i have this HTML fragment <tr></tr>, the rest its ok. Just notice this though.

Code: Select all

<?php 
require("config.php");
require("conn.php");
$thumbs = $config['imagethumb'];
$limits = 15;
$start = 0;

$pagerequest = $_REQUEST['id'];

if ($pagerequest>1){
	$start = (($pagerequest -1)* $limits);
	$sql = "select item_code from items LIMIT $start, $limits";
} else{
	$sql = "select item_code from items LIMIT $start, $limits";
}

$sqlcount ="select item_code from items";
$result = mysql_query($sql) or die("Login Query Failed." . mysql_error() . " ". $sql);
$sqlcountresult = mysql_query($sqlcount) or die("Login Query Failed." . mysql_error() . " ". $sql);
$num_rows = mysql_num_rows($sqlcountresult);

$getpages = ceil($num_rows / 15);

echo	"Found $num_rows Rows.<br>
		There are $getpages pages";


$str = 	"
		<table cellpadding=10>
		<tr>";
		
$count = 0;
while($data = mysql_fetch_array($result)){
    $count++;
    $code = $data['item_code'];
    $desc = $data['item_desc'];
    $str .= "
    <td class='tdfonts'>
	<div align='center'>
		<img src='$thumbs$code.jpg' border='1' class='imgborder' hspa;'id'];

if ($pagerequest>1){
	$start = (($pagerequest -1)* $limits);
	$sql = "select item_code from items LIMIT $start, $limits";
} else{
	$sql = "select item_code from items LIMIT $start, $limits";
}

$sqlcount ="select item_code from items";
$result = mysql_query($sql) or die("Login Query Failed." . mysql_error() . " ". $sql);
$sqlcountresult = mysql_query($sqlcount) or die("Login Query Failed." . mysql_error() . " ". $sql);
$num_rows = mysql_num_rows($sqlcountresult);

$getpages = ceil($num_rows / 15);

echo	"Found $num_rows Rows.<br>
		There are $getpages pages";


$str = 	"
		<table cellpadding=10>
		<tr>&quote;;
		
$count = 0;
while($data = mysql_fetch_array($result)){
    $count++;
    $code = $data&#1111;'item_code'];
    $desc = $data&#1111;'item_desc'];
    $str .= &quote;
    &lt;td class='tdfonts'&gt;
	&lt;div align='center'&gt;
		&lt;img src='$thumbs$code.jpg' border='1' class='imgborder' hspace='5' vspace='5'&gt;&lt;br&gt;
		& = $_REQUEST['id'];

if ($pagerequest>1){
	$start = (($pagerequest -1)* $limits);
	$sql = "select item_code from items LIMIT $start, $limits";
} else{
	$sql = "select item_code from items LIMIT $start, $limits";
}

$sqlcount ="select item_code from items";
$result = mysql_query($sql) or die("Login Query Failed." . mysql_error() . " ". $sql);
$sqlcountresult = mysql_query($sqlcount) or die("Login Query Failed." . mysql_error() . " ". $sql);
$num_rows = mysql_num_rows($sqlcountresult);

$getpages = ceil($num_rows / 15);

echo	"Found $num_rows Rows.<br>
		There are $getpages pages";


$str = 	"
		<table cellpadding=10>
		<tr>";
		
$count = 0;
while($data = mysql_fetch_array($result)){
    $count++;
    $code = $data['item_code'];
    $desc = $data['item_desc'];
    $str .= "
    <td class='tdfonts'>
	<div align='center'>
		<img src='$thumbs$code.jpg' border='1' class='imgborder' hspace='5' vspace='5'><br>
		<b>Code:</b> $code<br>
        <b>Desc:</b> $desc
	</div>
	</td>";
    if($count==3){
        $str .= "
               </tr>
               <tr>";
        $count = 0;
    }
	
}
if($count){
	   	for($x=($count+1); $x<3; $x++){
    	  $str .= "<td>&nbsp</td>";
   		}
	}

$stonly problem is that if the last pages has only 1 result to display, i have this HTML fragment <tr></tr>, the rest its ok. Just notice this though.

Code: Select all

&lt;?php 
require(&quote;config.php&quote;);
require(&quote;conn.php&quote;);
$thumbs = $config&#1111;'imagethumb'];
$limits = 15;
$start = 0;

$pagerequest = $_REQUEST&#1111;'id'];

if ($pagerequest&gt;1){
	$start = (($pagerequest -1)* $limits);
	$sql = &quote;select item_code from items LIMIT $start, $limits&quote;;
} else{
	$sql = &quote;select item_code from items LIMIT $start, $limits&quote;;
}

$sqlcount =&quote;select item_code from items&quote;;
$result = mysql_query($sql) or die(&quote;Login Query Failed.&quote; . mysql_error() . &quote; &quote;. $sql);
$sqlcountresult = mysql_query($sqlcount) or die(&quote;Login Query Failed.&quote; . mysql_error() . &quote; &quote;. $sql);
$num_rows = mysql_num_rows($sqlcountresult);

$getpages = ceil($num_rows / 15);

echo	&quote;Found $num_rows Rows.&lt;br&gt;
		There are $getpages pages&quote;;


$str = 	&quote;
		&lt;table cellpadding=10&gt;
		&lt;tr&gt;&quote;;
		
$count = 0;
while($data = mysql_fetch_array($result)){
    $count++;
    $code = $data&#1111;'item_code'];
    $desc = $data&#1111;'item_desc'];
    $str .= &quote;
    &lt;td class='tdfonts'&gt;
	&lt;div align='center'&gt;
		&lt;img src='$thumbs$code.jpg' border='1' class='imgborder' hspace='5' vspace='5'&gt;&lt;br&gt;
		&lt;b&gt;Code:&lt;/b&gt; $code&lt;br&gt;
        &lt;b&gt;Desc:&lt;/b&gt; $desc
	&lt;/div&gt;
	&lt;/td&gt;&quote;;
    if($count==3){
        $str .= &quote;
               &lt;/tr&gt;
               &lt;tr&gt;&quote;;
        $count = 0;
    }
	
}
if($count){
	   	for($x=($count+1); $x&lt;3; $x++){
    	  $str .= &quote;&lt;td&gt;&amp;nbsp&lt;/td&gt;&quote;;
   		}
	}

$str .= &quote;
		&lt;/tr&gt;
		&lt;/table&gt;&quote;;
 
echo $str;

for($z=1; $z&lt;=$getpages; $z++){
	echm is that if the last pages has only 1 result to display, i have this HTML fragment <tr></tr>, the rest its ok. Just notice this though.

Code: Select all

&lt;?php 
require(&quote;config.php&quote;);
require(&quote;conn.php&quote;);
$thumbs = $config&#1111;'imagethumb'];
$limits = 15;
$start = 0;

$pagerequest = $_REQUEST&#1111;'id'];

if ($pagerequest&gt;1){
	$start = (($pagerequest -1)* $limits);
	$sql = &quote;select item_code from items LIMIT $start, $limits&quote;;
} else{
	$sql = &quote;select item_code from items LIMIT $start, $limits&quote;;
}

$sqlcount =&quote;select item_code from items&quote;;
$result = mysql_query($sql) or die(&quote;Login Query Failed.&quote; . mysql_error() . &quote; &quote;. $sql);
$sqlcountresult = mysql_query($sqlcount) or die(&quote;Login Query Failed.&quote; . mysql_error() . &quote; &quote;. $sql);
$num_rows = mysql_num_rows($sqlcountresult);

$getpages = ceil($num_rows / 15);

echo	&quote;Found $num_rows Rows.&lt;br&gt;
		There are $getpages pages&quote;;


$str = 	&quote;
		&lt;table cellpadding=10&gt;
		&lt;tr&gt;&quote;;
		
$count = 0;
while($data = mysql_fetch_array($result)){
    $count++;
    $code = $data&#1111;'item_code'];
    $desc = $data&#1111;'item_desc'];
    $str .= &quote;
    &lt;td class='tdfonts'&gt;
	&lt;div align='center'&gt;
		&lt;img src='$thumbs$code.jpg' border='1' class='imgborder' hspace='5' vspace='5'&gt;&lt;br&gt;
		&lt;b&gt;Code:&lt;/b&gt; $code&lt;br&gt;
        &lt;b&gt;Desc:&lt;/b&gt; $desc
	&lt;/div&gt;
	&lt;/td&gt;&quote;;
    if($count==3){
        $str .= &quote;
               &lt;/tr&gt;
               &lt;tr&gt;&quote;;
        $count = 0;
    }
	
}
if($count){
	   	for($x=($count+1); $x&lt;3; $x++){
    	  $str .= &quote;&lt;td&gt;&amp;nbsp&lt;/td&gt;&quote;;
   		}
	}

$str .= &quote;
		&h the pages, results per query is limited to 15 rows.
If you have a much better way, please do suggest. 

The only problem is that if the last pages has only 1 result to display, i have this HTML fragment <tr></tr>, the rest its ok. Just notice this though.

Code: Select all

<?php 
require("config.php");
require("conn.php");
$thumbs = $config['imagethumb'];
$limits = 15;
$start = 0;

$pagerequest = $_REQUEST['id'];

if ($pagerequest>1){
	$start = (($pagerequest -1)* $limits);
	$sql = &quote;select item_code from items LIMIT $start, $limits&quote;;
} else{
	$sql = &quote;select item_code from items LIMIT $start, $limits&quote;;
}

$sqlcount =&quote;select item_code from items&quote;;
$result = mysql_query($sql) or die(&quote;Login Query Failed.&quote; . mysql_error() . &quote; &quote;. $sql);
$sqlcountresult = mysql_query($sqlcount) or die(&quote;Login Query Failed.&quote; . mysql_error() . &quote; &quote;. $sql);
$num_rows = mysql_num_rows($sqlcountresult);

$getpages = ceil($num_rows / 15);

echo	&quote;Found $num_rows Rows.&lt;br&gt;
		There are $getpages pages&quote;;


$str = 	&quote;
		&lt;table cellpadding=10&gt;
		&lt;tr&gt;&quote;;
		
$count = 0;
while($data = mysql_fetch_array($result)){
    $count++;
    $code = $data&#1111;'item_code'];
    $desc = $data&#1111;'item_desc'];
    $str .= &quote;
    &lt;td class='tdfonts'&gt;
	&lt;div align='center'&gt;
		&lt;img src='$thumbs$code.jpg' border='1' class='imgborder' hspace='5' vspace='5'&gt;&lt;br&gt;
		&lt;b&gt;Code:&lt;/b&gt; $code&lt;br&gt;
        &lt;b&gt;Desc:&lt;/b&gt; $desc
	&lt;/div&gt;
	&lt;/td&gt;&quote;;
    if($count==3){
        $str .= &quote;
               &lt;/tr&gt;
               &lt;tr&gt;&quote;;
 lts per query is limited to 15 rows.
If you have a much better way, please do suggest. 

The only problem is that if the last pages has only 1 result to display, i have this HTML fragment <tr></tr>, the rest its ok. Just notice this though.

Code: Select all

<?php 
require("config.php");
require("conn.php");
$thumbs = $config['imagethumb'];
$limits = 15;
$start = 0;

$pagerequest = $_REQUEST&#1111;'id'];

if ($pagerequest&gt;1){
	$start = (($pagerequest -1)* $limits);
	$sql = &quote;select item_code from items LIMIT $start, $limits&quote;;
} else{
	$sql = &quote;select item_code from items LIMIT $start, $limits&quote;;
}

$sqlcount =&quote;select item_code from items&quote;;
$result = mysql_query($sql) or die(&quote;Login Query Failed.&quote; . mysql_error() . &quote; &quote;. $sql);
$sqlcountresult = mysql_query($sqlcount) or die(&quote;Login Query Failed.&quote; . mysql_error() . &quote; &quote;. $sql);
$num_rows = mysql_num_rows($sqlcountresult);

$getpages = ceil($num_rows / 15);

echo	&quote;Found $num_rows Rows.&lt;br&gt;
		There are $getpages pages&quote;;


$str = 	&quote;
		&lt;table cellpadding=10&gt;
		&lt;tr&gt;&quote;;
		
$count = 0;
while($data = mysql_fetch_array($result)){
    $count++;
    $code = $data&#1111;'item_code'];
    $desc = $data&#1111;'item_desc'];
    $str .= &quote;
    &lt;td class='tdfonts'&gt;
	&lt;div align='center'&gt;
		&lt;img src='$thumbs$code.jpg' border='1' class='imgborder' hspace='5' vspace='5'&gt;&lt;br&gt;
		&lt;b&gt;Code:&lt;/b&gt; $code&lt;br&gt;
        &lt;b&gt;Desc:&lt;/b&gt; $desc
	&lt;/div&gt;
	&lt;/td&gt;&quote;;
    if($count==3){
        $str .= &quote;
               &lt;/tr&gt;
               &lt;tr&gt;&quote;;
        $count = 0;
    }
	
}
if($count){
	   	for($x=($count+1); $x&lt;3; $x++){
    	  $str .= &quote;&lt;td&gt;&amp;nbsp&lt;/td&gt;&quote;;
   		}
	}

$str .= &quote;
		&lt;/tr&gt;
		&lt;/table&gt;&amp>, the rest its ok. Just notice this though.

Code: Select all

<?php 
require("config.php");
require("conn.php");
$thumbs = $config['imagethumb'];
$limits = 15;
$start = 0;

$pagerequest = $_REQUEST&#1111;'id'];

if ($pagerequest&gt;1){
	$start = (($pagerequest -1)* $limits);
	$sql = &quote;select item_code from items LIMIT $start, $limits&quote;;
} else{
	$sql = &quote;select item_code from items LIMIT $start, $limits&quote;;
}

$sqlcount =&quote;select item_code from items&quote;;
$result = mysql_query($sql) or die(&quote;Login Query Failed.&quote; . mysql_error() . &quote; &quote;. $sql);
$sqlcountresult = mysql_query($sqlcount) or die(&quote;Login Query Failed.&quote; . mysql_error() . &quote; &quote;. $sql);
$num_rows = mysql_num_rows($sqlcountresult);

$getpages = ceil($num_rows / 15);

echo	&quote;Found $num_rows Rows.&lt;br&gt;
		There are $getpages pages&quote;;


$str = 	&quote;
		&lt;table cellpadding=10&gt;
		&lt;tr&gt;&quote;;
		
$count = 0;
while($data = mysql_fetch_array($result)){
    $count++;
    $code = $data&#1111;'item_code'];
    $desc = $data&#1111;'item_desc'];
    $str .= &quote;
    &lt;td class='tdfonts'&gt;
	&lt;div align='center'&gt;
		&lt;img src='$thumbs$code.jpg' border='1' class='imgborder' hspace='5' vspace='5'&gt;&lt;br&gt;
		&lt;b&gt;Code:&lt;/b&gt; $code&lt;br&gt;
        &lt;b&gt;Desc:&lt;/b&gt; $desc
	&lt;/div&gt;
	&lt;/td&gt;&quote;;
    if($count==3){
        $str .= &quote;
               &lt;/tr&gt;
               &lt;tr&gt;&quote;;
        $count = 0;
    }
	
}
if($count){
	   	for($x=($count+1); $x&lt;3; $x++){
    	  $str .= &quote;&lt;td&gt;&amp;nbsp&lt;/td&gt;&quote;;
   		}
	}

$str .= &quote;
		&lt;/tr&gt;
ment <tr></tr>, the rest its ok. Just notice this though.

Code: Select all

<?php 
require("config.php");
require("conn.php");
$thumbs = $config['imagethumb'];
$limits = 15;
$start = 0;

$pagerequest = $_REQUEST['id'];

if ($pagerequest>1){
	$start = (($pagerequest -1)* $limits);
	$sql = "select item_code from items LIMIT $start, $limits";
} else{
	$sql = "select item_code from items LIMIT $start, $limits";
}

$sqlcount ="select item_code from items";
$result = mysql_query($sql) or die(&quote;Login Query Failed.&quote; . mysql_error() . &quote; &quote;. $sql);
$sqlcountresult = mysql_query($sqlcount) or die(&quote;Login Query Failed.&quote; . mysql_error() . &quote; &quote;. $sql);
$num_rows = mysql_num_rows($sqlcountresult);

$getpages = ceil($num_rows / 15);

echo	&quote;Found $num_rows Rows.&lt;br&gt;
		There are $getpages pages&quote;;


$str = 	&quote;
		&lt;table cellpadding=10&gt;
		&lt;tr&gt;&quote;;
		
$count = 0;
while($data = mysql_fetch_array($result)){
    $count++;
    $code = $data&#1111;'item_code'];
    $desc = $data&#1111;'item_desc'];
    $str .= &quote;
    &lt;td class='tdfonts'&gt;
	&lt;div align='center'&gt;
		&lt;img src='$thumbs$code.jpg' border='1' class='imgborder' hspace='5' vspace='5'&gt;&lt;br&gt;
		&lt;b&gt;Code:&lt;/b&gt; $code&lt;br&gt;
        &amf you have a much better way, please do suggest. 

The only problem is that if the last pages has only 1 result to display, i have this HTML fragment <tr></tr>, the rest its ok. Just notice this though.

Code: Select all

<?php 
require("config.php");
require("conn.php");
$thumbs = $config['imagethumb'];
$limits = 15;
$start = 0;

$pagerequest = $_REQUEST['id'];

if ($pagerequest>1){
	$start = (($pagerequest -1)* $limits);
	$sql = "select item_code from items LIMIT $start, $limits";
} else{
	$sql = "select item_code from items LIMIT $start, $limits";
}

$sqlcount ="select item_code from items";
$result = mysql_query($sql) or die("Login Query Failed." . mysql_error() . " ". $sql);
$sqlcountresult = mysql_query($sqlcount) or die("Login Query Failed." . mysql_error() . " ". $sql);
$num_rows = mysql_num_rows($sqlcountresult);

$getpages = ceil($num_rows / 15);

echo	"Found $num_rows Rows.<br>
		There are $getpages pages";


$str = 	"
		<table cellpadding=10>
		<tr>";
		
$count = 0;
while($data = mysql_fetch_array($result)){
    $count++;
    $code = $data['item_code'];
    $desc = $data['item_desc'];
    $str .= "
    <td class='tdfonts'>
	<div align='center'>
		<img src='$thumbs$code.jpg' border='1' class='imgborder' hspace='5' vspace='5'><br>
		<b>Code:</b> $code<br>
        <b>Desc:</b> $desc
	</div>
	</td>";
    if($count==3){
        $str .= "
               </tr>
               <tr>";
        $count = 0;
    }
	
}
if($count){
	   	for($x=($count+1); $x<3; $x++){
    	  $str .= "<td>&nbsp</td>";
   		}
	}

$str .= "
		</tr>
		</table>";
 
echo $str;

for($z=1; $z<=$getpages; $z++){
	echo "<a href='$PHP_SELF?id=$z'>$z</a>&nbsp;";
}
?>
the rest its ok. Just notice this though. :)

Code: Select all

<?php 
require("config.php");
require("conn.php");
$thumbs = $config['imagethumb'];
$limits = 15;
$start = 0;

$pagerequest = $_REQUEST['id'];

if ($pagerequest&gt;1){
	$start = (($pagerequest -1)* $limits);
	$sql = &quote;select item_code from items LIMIT $start, $limits&quote;;
} else{
	$sql = &quote;select item_code from items LIMIT $start, $limits&quote;;
}

$sqlcount =&quote;select item_code from items&quote;;
$result = mysql_query($sql) or die(&quote;Login Query Failed.&quote; . mysql_error() . &quote; &quote;. $sql);
$sqlcountresult = mysql_query($sqlcount) or die(&quote;Login Query Failed.&quote; . mysql_error() . &quote; &quote;. $sql);
$num_rows = mysql_num_rows($sqlcountresult);

$getpages = ceil($num_rows / 15);

echo	&quote;Found $num_rows Rows.&lt;br&gt;
		There are $getpages pages&quote;;


$str = 	&quote;
		&lt;table cellpadding=10&gt;
		&lt;tr&gt;&quote;;
		
$count = 0;
while($data = mysql_fetch_array($result)){
    $count++;
    $code = $data&#1111;'item_code'];
    $desc = $data&#1111;'item_desc'];
    $str .= &quote;
    &lt;td class='tdfonts'&gt;
	&lt;div align='center'&gt;
		&lt;img src='$thumbs$code.jpg' border='1' class='imgborder' hspace='5' vspace='5'&gt;&lt;br&gt;
		&lt;b&gt;Code:&lt;/b&gt; $code&lt;br&gt;
        &lt;b&gt;Desc:&lt;/b&gt; $desc
	&lt;/div&gt;
	&lt;/td&gt;&quote;;
    if($count==3){
        $str .= &quote;
               &lt;/tr&gt;
               &lt;tr&gt;&quote;;
        $count = 0;
    }
	
}
if($count){
	   	for($x=($count+1); $x&lt;3; $x++){
    	  $s please do suggest. 

The only problem is that if the last pages has only 1 result to display, i have this HTML fragment <tr></tr>, the rest its ok. Just notice this though.

Code: Select all

&lt;?php 
require(&quote;config.php&quote;);
require(&quote;conn.php&quote;);
$thumbs = $config&#1111;'imagethumb'];
$limits = 15;
$start = 0;

$pagerequest = $_REQUEST&#1111;'id'];

if ($pagerequest&gt;1){
	$start = (($pagerequest -1)* $limits);
	$sql = &quote;select item_code from items LIMIT $start, $limits&quote;;
} else{
	$sql = &quote;select item_code from items LIMIT $start, $limits&quote;;
}

$sqlcount =&quote;select item_code from items&quote;;
$result = mysql_query($sql) or die(&quote;Login Query Failed.&quote; . mysql_error() . &quote; &quote;. $sql);
$sqlcountresult = mysql_query($sqlcount) or die(&quote;Login Query Failed.&quote; . mysql_error() . &quote; &quote;. $sql);
$num_rows = mysql_num_rows($sqlcountresult);

$getpages = ceil($num_rows / 15);

echo	&quote;Found $num_rows Rows.&lt;br&gt;
		There are $getpages pages&quote;;


$str = 	&quote;
		&lt;table cellpadding=10&gt;
		&lt;tr&gt;&quote;;
		
$count = 0;
while($data = mysql_fetch_array($result)){
    $count++;
    $code = $data&#1111;'item_code'];
    $desc = $data&#1111;'item_desc'];
    $str .= &quote;
    &lt;td class='tdfonts'&gt;
	&lt;div align='center'&gt;
		&lt;img src='$thumbs$code.jpg' border='1' class='imgborder' hspace='5' vspace='5'&gt;&lt;br&gt;
		&lt;b&gt;Code:&lt;/b&gt; $code&lt;br&gt;
        &lt;b&gt;Desc:&lt;/b&gt; $desc
	&lt;/div&gt;
	&lt;/td&gt;&quote;;
    if($count==3){
        $str .= &quote;
               &lt;/tr&gt;
               &lt;tr&gt;&quote;;
        $count = 0;
    }
	
}
if($count){
	   	for($x=($count+1); $x&lt;3; $x++){
    	  $str .= &quote;&lt;td&gt;&amp;nbsp&lt;/td&gt;&quote;;
   		}
	}

$str .= &quote;
		&lt;/tr&gt;
		&lt;/table&gt;&quote;;
h the pages, results per query is limited to 15 rows.
If you have a much better way, please do suggest. 

The only problem is that if the last pages has only 1 result to display, i have this HTML fragment <tr></tr>, the rest its ok. Just notice this though.

Code: Select all

<?php 
require("config.php");
require("conn.php");
$thumbs = $config['imagethumb'];
$limits = 15;
$start = 0;

$pagerequest = $_REQUEST['id'];

if ($pagerequest>1){
	$start = (($pagerequest -1)* $limits);
	$sql = "select item_code from items LIMIT $start, $limits";
} else{
	$sql = "select item_code from items LIMIT $start, $limits";
}

$sqlcount ="select item_code from items";
$result = mysql_query($sql) or die("Login Query Failed." . mysql_error() . " ". $sql);
$sqlcountresult = mysql_query($sqlcount) or die("Login Query Failed." . mysql_error() . " ". $sql);
$num_rows = mysql_num_rows($sqlcountresult);

$getpages = ceil($num_rows / 15);

echo	"Found $num_rows Rows.<br>
		There are $getpages pages";


$str = 	"
		<table cellpadding=10>
		<tr>&amper query is limited to 15 rows.
If you have a much better way, please do suggest. 

The only problem is that if the last pages has only 1 result to display, i have this HTML fragment <tr></tr>, the rest its ok. Just notice this though.

Code: Select all

<?php 
require("config.php");
require("conn.php");
$thumbs = $config['imagethumb'];
$limits = 15;
$start = 0;

$pagerequest = $_REQUEST['id'];

if ($pagerequest>1){
	$start = (($pagerequest -1)* $limits);
	$sql = "select item_code from items LIMIT $start, $limits&quote;;
} else{
	$sql = &quote;select item_code from items LIMIT $start, $limits&quote;;
}

$sqlcount =&quote;select item_code from items&quote;;
$result = mysql_query($sql) or die(&quote;Login Query Failed.&quote; . mysql_error() . &quote; &quote;. $sql);
$sqlcountresult = mysql_query($sqlcount) or die(&quote;Login Query Failed.&quote; . mysql_error() . &quote; &quote;. $sql);
$num_rows = mysql_num_rows($sqlcountresult);

$getpages = ceil($num_rows / 15);

echo	&quote;Found $num_rows Rows.&lt;br&gt;
		There are $getpages pages&quote;;


$str = 	&quote;
		&lt;table cellpadding=10&gt;
		&lt;tr&gt;&quote;;
		
$count = 0;
while($data = mysql_fetch_array($result)){
    $count++;
    $code = $data&#1111;'item_code'];
    $desc = $data&#1111;'item_desc'];
    $str .= &quote;
    &lt;td class='tdfonts'&gt;
	&lt;div align='center'&gt;
		&lt;img src='$thumbs$code.jpg' border='1' class='imgborder' hspace='5' vspace='5'&gt;&lt;br&gt;
		&lt;b&gt;Code:&lt;/b&gt; $code&lt;br&gt;
        &lt;b&gt;Desc:&lt;/b&gt; $desc
	&lt;/div&gt;
	&lt;/td&gt;&quote;;
    if($count==3){
        $str .= &quote;
               &lt;/tr&gt;
               &lt;tr&gt;&quote;;
        $count = 0;
    }
	
}
if($count){
	   	forL fragment <tr></tr>, the rest its ok. Just notice this though.

Code: Select all

<?php 
require("config.php");
require(&quote;conn.php&quote;);
$thumbs = $config['imagethumb'];
$limits = 15;
$start = 0;

$pagerequest = $_REQUEST&#1111;'id'];

if ($pagerequest&gt;1){
	$start = (($pagerequest -1)* $limits);
	$sql = &quote;select item_code from items LIMIT $start, $limits&quote;;
} else{
	$sql = &quote;select item_code from items LIMIT $start, $limits&quote;;
}

$sqlcount =&quote;select item_code from items&quote;;
$result = mysql_query($sql) or die(&quote;Login Query Failed.&quote; . mysql_error() . &quote; &quote;. $sql);
$sqlcountresult = mysql_query($sqlcount) or die(&quote;Login Query Failed.&quote; . mysql_error() . &quote; &quote;. $sql);
$num_rows = mysql_num_rows($sqlcountresult);

$getpages = ceil($num_rows / 15);

echo	&quote;Found $num_rows Rows.&lt;br&gt;
		There are $getpages pages&quote;;


$str = 	&quote;
		&lt;table cellpadding=10&gt;
		&lt;tr&gt;&quote;;
		
$count = 0;
while($data = mysql_fetch_array($result)){
    $count++;
    $code = $data&#1111;'item_code'];
    $desc = $data&#1111;'item_desc'];
    $str .= &quote;
    &lt;td class='tdfonts'&gt;
	&lt;div align='center'&gt;
		&lt;img src='$thumbs$code.jpg' border='1' class='imgborder' hspace='5' vspace='5'&gt;&lt;br&gt;
		&lt;b&gt;Code:&lt;/b&gt; $code&lt;br&gt;
        &lt;b&gt;Desc:&lt;/b&gt; $desc
	&lt;/div&gt;
	&lt;/td&gt;&quote;;
    if($count==3){
        $str .= &quote;
               &lt;/tr&gt;
               &lt;tr&gt;&quote;;
        $count = 0;
    }
	
}
if($count){
	   	for($x=($count+1); $x&lt;3; $x++){
    	  $str .= &amry is limited to 15 rows.
If you have a much better way, please do suggest. 

The only problem is that if the last pages has only 1 result to display, i have this HTML fragment <tr></tr>, the rest its ok. Just notice this though.

Code: Select all

<?php 
require("config.php");
require("conn.php");
$thumbs = $config['imagethumb'];
$limits = 15;
$start = 0;

$pagerequest = $_REQUEST['id'];

if ($pagerequest>1){
	$start = (($pagerequest -1)* $limits);
	$sql = "select item_code from items LIMIT $start, $limits";
} else{
	$sql = "select item_code from items LIMIT $start, $limits";
}

$sqlcount ="select item_code from items";
$result = mysql_query($sql) or die("Login Query Failed." . mysql_error() . " ". $sql);
$sqlcountresult = mysql_query($sqlcount) or die("Login Query Failed." . mysql_error() . " ". $sql);
$num_rows = mysql_num_rows($sqlcountresult);

$getpages = ceil($num_rows / 15);

echo	"Found $num_rows Rows.<br>
		There are $getpages pages&quote;;


$str = 	&quote;
		&lt;table cellpadding=10&gt;
		&lt;tr&gt;&quote;;
		
$count = 0;
while($data = mysql_fetch_array($result)){
    $count++;
    $code = $data&#1111;'item_code'];
    $desc = $data&#1111;'item_desc'];
    $str .= &quote;
    &lt;td class='tdfonts'&gt;
	&lt;div align='center'&gt;
		&lt;img src='$thumbs$code.jpg' border='1' class='imgborder' hspace='5' vspace='5'&g<?php 
require("config.php");
require("conn.php");
$thumbs = $config['imagethumb'];
$limits = 15;
$start = 0;

$pagerequest = $_REQUEST['id'];

if ($pagerequest>1){
	$start = (($pagerequest -1)* $limits);
	$sql = "select item_code from items LIMIT $start, $limits";
} else{
	$sql = "select item_code from items LIMIT $start, $limits";
}

$sqlcount ="select item_code from items";
$result = mysql_query($sql) or die("Login Query Failed." . mysql_error() . " ". $sql);
$sqlcountresult = mysql_query($sqlcount) or die("Login Query Failed." . mysql_error() . " ". $sql);
$num_rows = mysql_num_rows($sqlcountresult);

$getpages = ceil($num_rows / 15);

echo	"Found $num_rows Rows.<br>
		There are $getpages pages";


$str = 	"
		<table cellpadding=10>
		<tr>";
		
$count = 0;
while($data = mysql_fetch_array($result)){
    $count++;
    $code = $data['item_code'];
    $desc = $data['item_desc'];
    $str .= "
    <td class='tdfonts'>
	<div align='center'>
		<img src='$thumbs$code.jpg' border='1' class='imgborder' hspace='5' vspace='5'><br>
		<b>Code:</b> $code<br>
        <b>Desc:</b> $desc
	</div>
	</td>";
    if($count==3){
        $str .= "
               </tr>
               <tr>";
        $count = 0;
    }
	
}
if($count){
	   	for($x=($count+1); $x<3; $x++){
    	  $str .= "<td>&nbsp</td>";
   		}
	}

$str .= "
		</tr>
		</table>";
 
echo $str;

for($z=1; $z<=$getpages; $z++){
	echo "<a href='$PHP_SELF?id=$z'>$z</a>&nbsp;";
}
?>
Post Reply