Cibiņš Posted March 14, 2012 Report Share Posted March 14, 2012 (edited) Man ir divas tabulas. Viena, kurā glabājās dati, bet otra, kurā glabājās bildes. Chekošana notiek pēc hash. Diemžēl nesaprotu, kādēļ dati no imgs tabulas netiek izvadīti atbilstoši hash kontrolcipariem uz katru produktu? while ($row_category = mysql_fetch_assoc($query_prod)) { $prod_name=$row_category['prod_name']; $prod_description=$row_category['prod_description']; $prod_hash=$row_category['prod_hash']; $escaped_product_name=mysql_real_escape_string($prod_name); $escaped_product_description=mysql_real_escape_string($prod_description); $escaped_prod_hash=mysql_real_escape_string($prod_hash); $stripslashed_product_name=stripslashes($escaped_product_name); $stripslashed_product_description=stripslashes($escaped_product_description); $stripslashed_hash_new=stripslashes($escaped_prod_hash); $qryimgs = mysql_query("SELECT * FROM imgs WHERE images_hash = '".$stripslashed_hash_new."' ORDER BY images_upload_time ASC LIMIT 1")or die(mysql_error()); extract(mysql_fetch_array($qryimgs), EXTR_PREFIX_ALL, 'imga'); Ja piemēram liekam chekošanu vai ir vai nav attēls, tas sāk gļukot tiklīdz ir pievienoti vismaz divi ieraksti produktu tabulā. if(!$imga_imagename){ ?><img src="bildes_path/navbilde.jpg" /><? } else { ?><img src="bildes_path/<? echo $imga_imagename; } ?>" /> Kā lai palaiž kvēriju lai izvelk attiecīgo pēdējo pievienoto bildi un tabula negļukotu, tas ir, ja imgs tabulā nav bilžu attiecīgajam produktam, lai atspoguļo navbilde.jpg nevis taisa kosmiskus prikolus un vanda lapu ja abās tabulās ir vairāk bildes un produkti? Edited March 14, 2012 by Cibiņš Link to comment Share on other sites More sharing options...
Cibiņš Posted March 14, 2012 Author Report Share Posted March 14, 2012 Daaa sapratu.. $qryimgs = mysql_query("SELECT * FROM imgs WHERE images_hash = '".$stripslashed_hash_new."' ORDER BY images_upload_time ASC LIMIT 1")or die(mysql_error());<pre class="prettyprint">extract(mysql_fetch_array($qryimgs), EXTR_PREFIX_ALL, 'imga'); </pre> vajadzēja aizvietot ar $qryimgs = mysql_query("SELECT * FROM imgs WHERE images_hash = '".$prod_hash."' ORDER BY images_upload_time ASC LIMIT 1")or die(mysql_error()); $row = mysql_fetch_assoc($qryimgs); echo $row["imagename"] Link to comment Share on other sites More sharing options...
Recommended Posts