tehnic Posted August 14, 2009 Report Share Posted August 14, 2009 (edited) Ilgu laiku štukoju kā īsti panākt rezultātu bet man, kaut kas nesanāk. $dir = @ opendir("include/maps/"); while (($file = readdir($dir)) !== false) $map = mysql_query("SELECT * FROM `dmor`") or die(mysql_error()); while ($row = mysql_fetch_array($map)) { if ($file == $row['curmap']){ echo "<a href=\"include/dmmoni/index.php?width=275\" class=\"jTip\" id=\"divi\" name=\"Karte 1\"><img class=\"withmargin\" src=\"include/maps/" .$row['curmap']. ".gif\"></a>"; } else { echo "<a href=\"include/dmmoni/index.php?width=275\" class=\"jTip\" id=\"divi\" name=\"Karte 2\"><img class=\"withmargin\" src=\"include/maps/na.gif\"></a>"; } }; closedir($dir); Tā kā php vēl tikai mācos, tad štellēju kopā kā māku. Būtība tāda, vajad lai no db atlasa info par kādu karti mest virsū, pēc tam ar opendir atrod šo karti mapē, un attēlo viņu, ja šādas kartes nav, tad izmet na.gif vai vienalga ko. Bet - ja tāda karte ir - viņš padod pareizi, ja nav viņš no db nolasa un nesalīdzina kuru if vai else ir jāizpilda! Ceru ka skaidri izteicos! Piemēram: Folderī ir karte1 karte2 karte3 db padod ka tagad jaattēlo karte 1 if ($file == $row['curmap']){ ir ok izpildām - db padod ka tagad jaattēlo karte 5 if ($file == $row['curmap']){ katre nav - bet vienalga viņš padod Edited August 14, 2009 by tehnic Quote Link to comment Share on other sites More sharing options...
Aleksejs Posted August 14, 2009 Report Share Posted August 14, 2009 Es taisītu šādi: $map = mysql_query("SELECT * FROM `dmor`") or die(mysql_error()); while ($row = mysql_fetch_array($map)) { if(is_file('./include/maps/' . $row['curmap'] . '.gif')){ echo "<a href=\"include/dmmoni/index.php?width=275\" class=\"jTip\" id=\"divi\" name=\"Karte 1\"><img class=\"withmargin\" src=\"include/maps/" .$row['curmap']. ".gif\"></a>"; } else { echo "<a href=\"include/dmmoni/index.php?width=275\" class=\"jTip\" id=\"divi\" name=\"Karte 2\"><img class=\"withmargin\" src=\"include/maps/na.gif\"></a>"; } } Quote Link to comment Share on other sites More sharing options...
tehnic Posted August 14, 2009 Author Report Share Posted August 14, 2009 Paldies, strādā brīnišķīgi! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.