Ver Mensaje Individual
  #2 (permalink)  
Antiguo 15/03/2005, 17:51
Avatar de Seppo
Seppo
 
Fecha de Ingreso: marzo-2005
Ubicación: Buenos Aires, Argentina
Mensajes: 1.284
Antigüedad: 19 años, 1 mes
Puntos: 17
creo q ahi esta todo...

<?php

$conn = mysql_connect("x.com", "xxxx", "xxxx"); // datos SQL
mysql_select_db("xxxxx", $conn); // Nombre de la B.D

$q_total = mysql_query("SELECT count(*) as cantidad FROM products_to_categories");
$total = mysql_fetch_assoc($q_total);

if (!$_GET['pagina']) { $_GET['pagina'] = 0; }
$start = $_GET['pagina'] * 20;

$sql = "SELECT * FROM products_to_categories ORDER BY products_id LIMIT ".$start.", 20";
$records = mysql_query($sql, $conn);

Print "<table border=3 width=100% class='infoBoxContent'>";
Print "<tr><td>Ref</td><td>Categoría</td><td>Imagen</td><td>Descripción</td> <td>Precio</td> <td>PVD</td></tr>";
$i = 0;

while ($table = mysql_fetch_array($records)) {

$product = $table['products_id'];
$category = $table['categories_id'];
$desc_id = $product;

$sql = "SELECT categories_name, categories_id FROM categories_description WHERE categories_id = $category";
$category = mysql_query($sql, $conn);
$category = mysql_fetch_array($category);
$category = $category['categories_name'];

$sql = "SELECT products_id, products_model, products_price, products_pvd, products_image FROM products WHERE products_id = $product";
$product = mysql_query($sql, $conn);
$product = mysql_fetch_array($product);
$part = $product['products_id'];
$price = $product['products_price'];
$pvd = $product['products_pvd'];
$picture = $product['products_image'];
$price = substr($price,0, strlen($price) - 2);

$sql = "SELECT products_id, products_description FROM products_description WHERE products_id = $desc_id";
$description = mysql_query($sql, $conn);
$description = mysql_fetch_array($description);
$description = $description['products_description'];

if (!($i%2)) {

$color = "BGCOLOR = #FFFF99";

}

else {

$color = "BGCOLOR = #FFFFFF";

}

print "<tr><td>$part</td><td>$category</td><td>$picture</td><td>$description</td><td>$$price</td><td>$pvd</td></tr>";

$i++;

}
if ($total['cantidad'] > 0) {
echo "<tr>";
if ($_GET['pagina'] > 0) {
$prev_pag = $_GET['pagina'] - 1;
echo "<td><a href=\"".$_SERVER['PHP_SELF']."\">Primer pagina</a></td><td><a href=\"".$_SERVER['PHP_SELF']."?pagina=".$prev_pag."\">Pagina anterior</a></td>";
}
$ultima = floor(20*$total['cantidad']);
if ($_GET['pagina'] < $ultima) {
$next_pag = $_GET['pagina'] + 1;
echo "<td><a href=\"".$_SERVER['PHP_SELF']."?pagina=".$next_pag."\">Ultima pagina</a></td><td><a href=\"".$_SERVER['PHP_SELF']."?pagina=".$ultima."\"></a></td>";
}
echo "</tr>";
}

print "</table>"

?>