EN` Posted November 19, 2008 Report Share Posted November 19, 2008 (edited) Ja kaads vareetu izskaidrot principu peec kaa veidot dinamisku case. Veelos, lai automaatiski tiek veidoti case. Pimeeram, ja man datubaazee jau ir kaut kaadas bildes, katrai bildei ir infa klaat. Ko vispaar un kaa vajadzeetu dariit, lai veidotos prieksh katras shiis bildes case, kad izsaucu tieshi nepiecieshamo bildi ar id? Piemeeram, shis ir parasts switch $p = $_GET['p']; switch($p) { case '1': print "bilde 1 un infa"; break; default: include('a.php'); break; } Peec kaada principa jaabuuvee, lai nevajadzeetu muljkjiigi katrai bildei raxtiit case '1';'2' utt? Vai varbuut case nav jaaizmanto shaadaa gadiijumaa? varbuut ir kaadi tuti, jo nezinu ar kaadiem vaardiem mekleet sho pasaakumu? Edited November 19, 2008 by EN` Link to comment Share on other sites More sharing options...
bubu Posted November 19, 2008 Report Share Posted November 19, 2008 Ja jau tu saki, ka tev datubāzē ir tās bildes un informācija par bildēm, tad nekādu switch'u nevajag. Vajag vilkt informāciju ārā no datubāzes. $p = (int)$_GET["p"]; $query = mysql_query("SELECT bilde, bildes_infa FROM bilžu_tabula WHERE bildes_id = $p") or die(mysql_error()); if ($row = mysql_fetch_assoc($query)) { list($bilde, $bildes_infa) = $row; echo "bilde=$bilde, bildes_infa=$bildes_infa"; } else { echo "nav tādas bildes"; } Link to comment Share on other sites More sharing options...
EN` Posted November 19, 2008 Author Report Share Posted November 19, 2008 Paldies par aatru atbildi. Rezultaataa man met aaraa echo - "url=, description=" Kaut kas man nepareizi? <?php mysql_select_db("portfolio", mysql_connect("localhost","root","")); $p = (int)$_GET["p"]; $query = mysql_query("SELECT url, description FROM gallery WHERE id = $p") or die(mysql_error()); if ($row = mysql_fetch_assoc($query)) { list($url, $description) = $row; echo "url=$url, description=$description"; } else { echo "nav tādas bildes"; } ?> Link to comment Share on other sites More sharing options...
andrisp Posted November 19, 2008 Report Share Posted November 19, 2008 Nē, viss ir pareizi. Pēc koda tā sanāk. :) Link to comment Share on other sites More sharing options...
EN` Posted November 19, 2008 Author Report Share Posted November 19, 2008 (edited) Pameegjinaaju savaadaak. Shaadi straadaa un izdod visu infu un urlu, bet ir 2 SELECTi, ja nonjem vienu, tad met erroru oO Var atstaat divus? $p = (int)$_GET["p"]; $query = mysql_query("SELECT url, description FROM gallery WHERE id = $p "); $sql = ("SELECT url, description FROM gallery WHERE id = $p "); $result = @mysql_query($sql) or die(mysql_error()); $row = mysql_fetch_array($result); if ($row = mysql_fetch_assoc($query)) { echo $row['url']; } else { include('latest.php'); } Edited November 19, 2008 by EN` Link to comment Share on other sites More sharing options...
bubu Posted November 19, 2008 Report Share Posted November 19, 2008 fui, nokļūdījos. mysql_fetch_assoc vietā manā kodā raksti mysql_fetch_row. Tavs pēdējais kods izskatās slimīgi. Kāpēc jātaisa lieks kverijs (to ko piešķir $query mainīgajam), ja tā rezultātus nemaz neizmanto? Link to comment Share on other sites More sharing options...
EN` Posted November 19, 2008 Author Report Share Posted November 19, 2008 Lūdzu nevajag taisīt bezjēdzīgas QUOTEs Paldies, viss straadaa. Esmu iesaaceejs, viegli uzraxtu un daru kaut ko nelogjisku. Link to comment Share on other sites More sharing options...
Recommended Posts