-1

Hi,

this is my page which is displaying the products that i inserted inside my database tables for example this is for one of them that named table1 :

<table width="850" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td>
<?php 
include "../db.php";
?>
<?php
error_reporting(0);
//Rows
$imgRow = '<tr>';
$idRow = '<tr>';
 
$nn=6; //Number of items, we split this later
 
$s=mysql_query("SELECT * FROM table1 "); 
 
$c=mysql_num_rows($s);
 
if($c%$nn==0){
	$cc=$c/$nn;	
}else{
	$cc=$c/$nn+1;	
}
 
//$cc : Number of pages
 
$ss=@$_REQUEST['ss']; //Start position (eg: 6)
$other_tables = "";
 
if($ss=="" || $ss==null){
	$ss = 0; //Set to zero because it is incremented later
}
 
//Pages
echo "<table border=\"0\" align=\"center\" style=\"text-align:center;\">";
$sql=mysql_query("SELECT * FROM table1 ORDER BY `id` DESC LIMIT $ss,$nn"); 
$inc = 0;
while($r=mysql_fetch_array($sql)){
	$key=$r['id'];
	$id=$r['name'];  
	$img=$r['pic1'];
	if($inc == 0){
		$imgRow .= "<tr>";
		$idRow .= "<tr>";
	}
	$imgRow .= "<td title=\"details\"><a href=\"showproducts1-details.php?id=$key\" target=\"_self\" ><img src=\"../admin/products/productimages1/$img\" width=\"270\" height=\"330\" border=\"1\" /></a></td>";
	$idRow .= "<td><a href=\"showproducts1-details.php?id=$key\">$id</a></td>";
	++$inc;
	if($inc == 3 || $inc == 6 || $inc == mysql_num_rows($sql)){
		//Display Table
		echo $imgRow."</tr>";
		echo $idRow."</tr>";
		echo "</table>";
        echo "<br>";echo "<br>";echo "<br>";
		//To remove extra table
		if(mysql_num_rows($sql) <= 3){
			$inc = 7;
		}
 
		//Reset
		if($inc == 3){
			echo "<table border=\"0\" align=\"center\" style=\"text-align:center;\">";
			$imgRow = "<tr>";
			$idRow = "<tr>";
		}
	}
}
echo "</table>";
echo "<br>";
?>  </td>
  </tr>
</table>

<table width="820" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td>
<?php
$j=0;
echo"page numbers : ";
for($i=1;$i<=$cc;$i++){
	echo"<a href=\"showproductsall-all.php?ss=$j\">$i</a>";
	echo"|";
	$j=$j+$nn; 
}
?>
</td>
  </tr>
</table>

i created 12 item of this page that each one of them displaying certain information from table1,table2,table3,....,table12

now i wanna show all of the products in one page as a all products page that contains no category.

how can i change the select query for selecting the all of tables and showing them in one page .

Also there is another question too :

$imgRow .= "<td title=\"details\"><a href=\"showproducts1-details.php?id=$key\" target=\"_self\" ><img src=\"../admin/products/productimages1/$img\" width=\"270\" height=\"330\" border=\"1\" /></a></td>";

what about this ? i created 12 folder for each table . how can i display them ?
please help me ?

2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by divyakrishnan
0

Use for loop to access tables.

for($i=1;$i<=12;$i++)
  {

$q="SELECT * FROM table".$i;
/*
Do ur table processing
*/

}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.