![]() |
![]() ![]() |
![]() |
![]()
Post
#1
|
|
Grupa: Zarejestrowani Postów: 2 Pomógł: 0 Dołączył: 22.04.2003 Ostrzeżenie: (0%) ![]() ![]() |
Witam serdecznie . mam mały kłopot z porcjowanie i sortowaniem danych. Mam sklep opart na plikach a z racji że nie mam serwera który obsługuję mysql to musi mi to wystarczać ...
Chodzi mi o to żeby lista produktów byla porcjowana a linki do poszczególnych stron wyglądały << 1 - 2 -3 - 4 - 5 - 6 - 7 >> itd .. oprucz tego przydało by się też sortowanie alfabetyczne ale mi to nie wychodzi próbował z sort() z asort() i z wszystkimi podobnymi funkcjami które powinny sortować ale nic z tego . Najważniejsze dla mnie jest to porcjowanie . poniżej fragment kodu . proszę o pomoc [php:1:79cc756a5d] <? // Display the shop header. This is the search box, category select, links etc. function dispHeader ($categ,$search,$cat) { ?> <SCRIPT LANGUAGE="JavaScript"> <!-- function jumpto(){ location = document.links.link_select.options[document.links.link_select.selectedIndex].val e } //--> </SCRIPT> <center> <table width="477" border="0" cellspacing="0" cellpadding="0"> <tr> <td> <p><table class="tableBackground" width="477" cellspacing="0" cellpadding="2"> <tr> <td><font class="titleFont">Store Options</font></td> </tr> </table> <table width="98%" border="0" cellspacing="0" cellpadding="0"> <form method="POST" name="links"> <tr> <td width="50%" valign="top"> <br><select name="link_select"> <P><option value="index.php">View all products <? $cartFile = File("dbase.txt"); $length = sizeof($cartFile); $i = 1; while ($i < $length) { list($categ) = explode("|",$cartFile[$i]); if (!$lookupAr[$categ]) { $lookupAr[$categ] = 1; $categ2 = "$categ"; $categ = ereg_replace("&","%26",$categ); $categ = ereg_replace(" ","%20",$categ); echo "<option value="index.php?cat=$categ">$categ2 n"; } $i++; } ?> </select> <input type="button" value="go" onClick="jumpto()"> </td> </form> <form method="post" action="index.php"> <td width="50%" align="right" valign="bottom"> <input type="hidden" name="option" value="search"> <input type="text" name="search" size="17" value="<?=$search?>"> <input type="submit" value="Search"> </td> </tr> </form> </table> <p align="right"><a href="index.php">Shop Front</a> | <a href="view.php">View Shopping</a> | <a href="checkout.php">Check Out</a> <? } ?> <? // Display the shop footer function dispFooter () { include("vars.php"); ?> <center> All prices quoted in <?=$currency?>. Prices are <? if ($tax == "") echo "exclusive "; else echo "inclusive "; ?> of <?=$tax_name?>. </center> </td> </tr> </table> <? } ?> <? // This will display each item function displayProd ($categ,$type,$id,$name,$itemoptions,$price,$normpr,$img,$stockop,$advdate,$deta ls,$desc) { include("vars.php"); ?> <tr> <td valign="top"> <? if ($img != "") { ?> <center> <img src="images/<?=$img?>" border="0"> <? if ($details != "") { ?> <p><font size="1"><a href="<?=$details?>">Click for more details</a> <? } ?> <? } ?> </td> <td width="30"></td> <td valign="top"> <font class="itemTitleFont"><b><?=$name?></b></font> <? if ($stockop == "advance") echo "<br><b>Advance Order Only</b> - Available $advdate"; elseif ($stockop == "outof") echo "<br><b>Out of Stock</b>"; ?> <p><?=$desc?> <? if ($stockop == "instock" || $stockop == "advance") { if ($type == "single") { if ($normpr != "") echo "<p>RRP: <strike>$cur$normpr</strike> | <font class="ourPrice"><b>Our Price: $cur$price</b></font>"; else echo "<p><font class="ourPrice"><b>Price: $cur$price</b></font>"; echo " | <input name="".$id."info" type="hidden" value="$name|$price"> "; } else { $tokAr = explode("~",$itemoptions); $numTok = sizeof($tokAr); for ($i=0;$i<$numTok;$i++) { if (trim($tokAr[$i])!="") { $tokformat = ereg_replace(" - ","|",$tokAr[$i]); $tok = ereg_replace(" - "," - $cur",$tokAr[$i]); $itemoptions2 .= "<option value="$name - $tokformat">$tok"; } } $itemoptions = $itemoptions2; echo "<p><select name="".$id."info">$itemoptions2</select> "; } ?> <input type="value" name="<?=$id?>quant" value="1" size="3"> <input type="button" name="<?=$id?>add" value="Add" onclick="addItem(document.itemsform.<?=$id?>info,document.itemsform.<?=$id?>quant.value)"> <? } ?> </td> </tr> <tr> <td colspan="3"><br><hr width="100%" size="1" noshade color="black"><br></td> </tr> <? } ?> [/php:1:79cc756a5d] |
|
|
![]()
Post
#2
|
|
Grupa: Zarejestrowani Postów: 196 Pomógł: 0 Dołączył: 29.04.2002 Skąd: jesteś? Ostrzeżenie: (0%) ![]() ![]() |
w sumei nie testowalem, trzeba by poczytac w manualu o dostepie do pliku, ale wydaje mi sie, ze zrobienie linkow nie jest najgorszym problemem, raczej wyswietlenie fragmentu pliku jest gorsze, bo tak czy owak musisz go wczytac calego, i wybrac tylko te linijki, ktore akurat maja byc wyswietlone...
masz taki fragment kodu: <? $cartFile = File("dbase.txt"); $length = sizeof($cartFile); $i = 1; $cartFile jest tablica, ktora zawiera wszystkie linijki (produkty) z pliku dbase.txt (o ile dobrze sie wczytalem) musisz teraz sprawdzic ile jest tych linijek, podzielic to ladnie na powiedzmy dziesiatki, zrobic linki. . a nastepnie wyswietlac tylko te linijki, ktore maja byc wyswietlone. . czyli na przyklad jak ktos kliknie na produkty 10-19 to tylko linijki 10-19 w razie niejasnosci, zapraszam na php.cba.pl |
|
|
![]() ![]() |
![]() |
Aktualny czas: 25.08.2025 - 20:38 |