test2 Posted March 25, 2008 Report Share Posted March 25, 2008 Tātad, man piemēram ir šāds rezultāts pēc mysql selecta: Galds | Cena balts 2 melns 3 brūns 4 zaļš 5 zils 6 dzeltens 7 tātad ši ir tabula izskatītas viņa varētu šādi: <table> <tr><th>Galds</th><th>Cena</th></tr> .... while($row = mysql_fetch_array( $result )) { echo "<tr><td>"; echo $row['galds']; echo "</td><td>"; echo $row['price']; echo "</td></tr>"; } echo "</table>"; A man šo te vajadzētu sadalīt uz pusi un tad izvadīt apmr tā: Galds_viena_puse | Cena_viena_puse balts 2 melns 3 brūns 4 Galds_otra_puse | Cena_otra_puse zaļš 5 zils 6 dzeltens 7 Ceru, ka sapratīsiet! Link to comment Share on other sites More sharing options...
andrisp Posted March 25, 2008 Report Share Posted March 25, 2008 ... LIMIT 0, 4 ... LIMIT 4, 4 ? Link to comment Share on other sites More sharing options...
test2 Posted March 25, 2008 Author Report Share Posted March 25, 2008 Laba ideja, bet vai tas būtu optimālākais variants? Link to comment Share on other sites More sharing options...
andrisp Posted March 25, 2008 Report Share Posted March 25, 2008 A tu točna zini, ka tev vienmār būs max 8 ieraksti, un viemēr vajadzēs dalīt pa četri ? Link to comment Share on other sites More sharing options...
test2 Posted March 25, 2008 Author Report Share Posted March 25, 2008 Nē nu es nezinu, bet pārbaudi tak vienkārši uztaisīt: $limits = $daudzums / 2; Link to comment Share on other sites More sharing options...
andrisp Posted March 25, 2008 Report Share Posted March 25, 2008 Nu tad jau nav problēmu. ;) Link to comment Share on other sites More sharing options...
marcis Posted March 25, 2008 Report Share Posted March 25, 2008 Jautājums jau atrisināts? $i=0; while(...) { ++$i; if($i%2==0){ echo '...'; } } Vai liec <div> elementos kolonas, jāskaita līdz būs jebkurā gadījumā. Link to comment Share on other sites More sharing options...
andrisp Posted March 26, 2008 Report Share Posted March 26, 2008 marcis, tavs kods to '...' izdrukaas katru reizi, kad $i daliisies ar 2 bez atlikuma. Link to comment Share on other sites More sharing options...
marcis Posted March 26, 2008 Report Share Posted March 26, 2008 (edited) andrisp, nevar būt. Ja es ciklā gribu izvadīt tabulu ar divām kolonām, es rakstu tā: $i=0; while(...){ ++$i; echo '<td></td>'; if($i%2==0){ echo '</tr><tr>'; } } Pareizi, ne? Edited March 26, 2008 by marcis Link to comment Share on other sites More sharing options...
andrisp Posted March 26, 2008 Report Share Posted March 26, 2008 (edited) Jā, pareizi, bet vai tad nesanāk, ka </tr><tr> tiks izdrukāts, ja $i dalīsies ar 2 bez atlikuma ? Un galu galā - ne jau to autors vēlējās. Autors vēlējās divas tabulas, nevis divas kolonnas. Edited March 26, 2008 by andrisp Link to comment Share on other sites More sharing options...
Recommended Posts