Autor Zpráva
Okay
Profil *
Dobrý den,
potřeboval bych radu ohledně úpravy e-shopu. Momentálně můj e-shop umí vypsat produkty pouze jeden do jednoho širokého rádku pod sebe - tedy 15 produktů = 15 rádků.
Cílem je dostat 3 produkty na jeden řádek - tedy tak aby se výrobky řadili do 3 sloupců, 15 produktů = 5 řádků. Programátor na to chce použit nějaké cykly, které by vždy napočítali do 3 a pak vytvořili nový řádek, ale zatím se mu to nedaří nastavit...

Porodí, prosím někde jak na to? :)
souki
Profil
Ano, ať to udělá přesně takhle :) Nevím co jiného bez křišťálové koule říct :)
Pokud ovšem jde o výpis i s obrázky atd, ať raději vypíše každé zboží do vlastního "boxu" a umístění na řádku nastaví pomocí CSS
domixx
Profil
1, 2, 3... he he

No, jestli jsem to pochopil...


for ($i=0;$i<$pocet_produktu;$i++) {
for($j=0;$j<3;$j++) {
echo "?????<div style="float: left">produkt</div>????";
}
$j = 0;
echo "????třeba nějakej dlouhej div pro oddělení (aby ten float - viz. výše - to neházel hala bala)";
}
Okay
Profil *
Níže posílám radši celý náš zdrojový kód řazení produktů. Stále se nedaří to napsat tak, aby to fungovalo. Produkty se teď řadí takhle:
1
2
3
4
5
6
7

Snažíme se to předělat do této podoby
1 2 3
4 5 6
7...


Zdrojový kód:

<?php if ($index_refer <> 1) { exit(include("./includes/exit.inc.php")); } ?>
<?php
$searchmethod = " AND "; //default

if (!empty($_POST['searchmethod'])) {
$searchmethod=$_POST['searchmethod'];
}
if (!empty($_GET['searchmethod'])) {
$searchmethod=$_GET['searchmethod'];
}
if (!empty($_POST['searchfor'])) {
$searchfor=$_POST['searchfor'];
}
if (!empty($_GET['search'])) {
$searchfor=$_GET['search'];
}
if (!empty($_GET['orderby'])) {
$orderby=$_GET['orderby'];
}
else { $orderby = "DESCRIPTION"; }
?>

<?php
if (!empty($cat)){
// find the product category
$query = sprintf("SELECT * FROM `category` where `ID`=%s", quote_smart($cat));
$sql = mysql_query($query) or die(mysql_error());

while ($row = mysql_fetch_row($sql)) {
$categorie = $row[1];
}
}
else {
$categorie = $txt['browse1'] . " / " . $searchfor;
}

// products per page
if ($products_per_page > 0) {
if (!empty($_GET['num_page'])) {
$num_page = $_GET['num_page'];
}
else { $num_page = 1; }
$start_record = ($num_page -1) * $products_per_page;
$limit = " LIMIT $start_record, $products_per_page";
}
else { $limit = ""; }
?>

<table width="100%" class="datatable">
<caption><?php echo $txt['browse9']; ?></caption>
<tr><th>
<?php
echo $txt['browse2']." / ".$categorie;
echo "<br />";
if ($action == "list") { echo "<a href="index.php?page=browse&action=list&group=$group&cat=$cat&orderby= DESCRIPTION"><small>".$txt['browse4']."</small></a>"; }
?>
</th><th>
<?php
echo "<div style="text-align:right;">";
echo $txt['browse3'];
// if we use VAT, then display that the prices are including VAT in the list below
if ($no_vat == 0) { echo " (".$txt['general7']." ".$txt['general5'].")"; }
echo "<br />";
if ($action == "list") { echo "<a href="index.php?page=browse&action=list&group=$group&cat=$cat&orderby= PRICE"><small>".$txt['browse4']."</small></a>"; }
echo "</div>";
?>
</th>
</tr>
<?php


if ($action == "list") {
if ($stock_enabled == 1 && IsAdmin() == false) { // filter out products with stock lower than 1
$query = sprintf("SELECT * FROM `product` where `STOCK` > 0 AND `CATID`=%s ORDER BY %s", quote_smart($cat), quote_smart($orderby));
}
else { $query = sprintf("SELECT * FROM `product` WHERE CATID=%s ORDER BY %s", quote_smart($cat), quote_smart($orderby)); }
}
elseif ($action == "shownew") {
if ($stock_enabled == 1 && IsAdmin() == false) { // filter out products with stock lower than 1
$query = sprintf("SELECT * FROM `product` WHERE `STOCK` > 0 AND `NEW` = '1' ORDER BY %s", quote_smart($orderby));
}
else { $query = sprintf("SELECT * FROM `product` WHERE `NEW` = '1' ORDER BY %s", quote_smart($orderby)); }
}

else {
//search on the given terms
$searchitem = explode (" ", $searchfor);
if ($stock_enabled == 1) {
$searchquery = "WHERE `STOCK` > 0 AND ((DESCRIPTION LIKE '%" . $searchitem[0] . "%') OR (PRODUCTID = '" . $searchitem[0] . "'))";
}
else { $searchquery = "WHERE ((DESCRIPTION LIKE '%" . $searchitem[0] . "%') OR (PRODUCTID = '" . $searchitem[0] . "'))"; }
$counter = 1;

while (!$searchitem[$counter] == NULL){
$searchquery = $searchquery . $searchmethod . "(DESCRIPTION LIKE '%" . $searchitem[$counter] . "%')";
$counter = $counter +1;
}
$query = "SELECT * FROM product $searchquery ORDER BY $orderby";
}
// total products without the limit
$sql = mysql_query($query) or die(mysql_error());
$num_products = mysql_num_rows($sql);

// products optionally with the limit
$sql = mysql_query($query.$limit) or die(mysql_error());
if (mysql_num_rows($sql) == 0) {
echo "<tr><td>".$txt['browse5']."</td><td>&nbsp;</td></tr></table>";
}
else {

$optel = 0;

while ($row = mysql_fetch_row($sql)) {
$optel++;
if ($optel == 3) { $optel = 1; }
if ($optel == 1) { $kleur = ""; }
if ($optel == 2) { $kleur = " class="altrow""; }

// the price gets calculated here
$printprijs = $row[4]; // from the database
if ($db_prices_including_vat == 0 && $no_vat == 0) { $printprijs = $row[4] * $vat; }
$printprijs = myNumberFormat($printprijs,$number_format); // format to our settings

// reset values
$picturelink = "";
$new = "";
$thumb = "";

// new product?
if ($row[7] == 1) { $new = "<font color="red"><strong>" . $txt['general3']. "</strong></font>"; }

// is there a picture?
if ($search_prodgfx == 1 && $use_prodgfx == 1) {

if ($pictureid == 1) { $picture = $row[0]; }
else { $picture = $row[1]; }

// determine resize of thumbs
$width = "";
$height = "";
if ($pricelist_thumb_width != 0) { $width = " width="".$pricelist_thumb_width."""; }
if ($pricelist_thumb_height != 0) { $height = " height="".$pricelist_thumb_height."""; }

if (thumb_exists($product_dir ."/". $picture . ".jpg")) { $thumb = "<img class="imgleft" src="".$product_dir."/".$picture.".jpg"".$width.$height." alt="" />"; }
if (thumb_exists($product_dir ."/". $picture . ".gif")) { $thumb = "<img class="imgleft" src="".$product_dir."/".$picture.".gif"".$width.$height." alt="" />"; }
if (thumb_exists($product_dir ."/". $picture . ".png")) { $thumb = "<img class="imgleft" src="".$product_dir."/".$picture.".png"".$width.$height." alt="" />"; }

// if the script uses make_thumbs, then search for thumbs
if ($make_thumbs == 1) {
if (thumb_exists($product_dir ."/tn_". $picture . ".jpg")) { $thumb = "<img class="imgleft" src="".$product_dir."/tn_".$picture.".jpg" alt="" />"; }
if (thumb_exists($product_dir ."/tn_". $picture . ".gif")) { $thumb = "<img class="imgleft" src="".$product_dir."/tn_".$picture.".gif" alt="" />"; }
if (thumb_exists($product_dir ."/tn_". $picture . ".png")) { $thumb = "<img class="imgleft" src="".$product_dir."/tn_".$picture.".png" alt="" />"; }
}

if ($thumb != "" && $thumbs_in_pricelist == 0) {
// use a photo icon instead of a thumb
$picturelink = "<a href="".
pepana
Profil *
zkus do toho zakomponovat CSS

Vaše odpověď

Mohlo by se hodit


Prosím používejte diakritiku a interpunkci.

Ochrana proti spamu. Napište prosím číslo dvě-sta čtyřicet-sedm:

0