Snukzz Posted December 2, 2004 Report Share Posted December 2, 2004 Rekur skripc kuram buutu jaaizvada no datu baazes atbilstoshaas veertiibas. <? $sub_kat_id=user_num($_GET['skatid']); $res4=mysql_query('SELECT * from FEATURES'); if($sub_kat_id == 1) { // TV $res5 = array('diagonaale' => 'Diagonāle', 'skana' => 'Skaņa', 'av_in' => 'Audio/Video ieeja', 'av_out' => 'Audio/Video izeja'); } $query = "SELECT ".implode(',',array_keys($res4))." FROM preces WHERE sub_kat_id=$skatid"; ?> Tas ir-a pareizi, vai tikai mani PHP chakeree...! Shis man sak' Warning: array_keys(): The first argument should be an array in D:\WEB\ILB\include\feat.php on line 13 Warning: implode(): Bad arguments. in D:\WEB\ILB\include\feat.php on line 13 Warning: Invalid argument supplied for foreach() in D:\WEB\ILB\include\feat.php on line 38 help! :ph34r: Link to comment Share on other sites More sharing options...
Venom Posted December 2, 2004 Report Share Posted December 2, 2004 neredzu nedz foreach, nedz mysql_fetch_* no res4 Link to comment Share on other sites More sharing options...
Snukzz Posted December 2, 2004 Author Report Share Posted December 2, 2004 aaa...paga :D Link to comment Share on other sites More sharing options...
Venom Posted December 2, 2004 Report Share Posted December 2, 2004 neredzu nedz foreach, nedz mysql_fetch_* Link to comment Share on other sites More sharing options...
Snukzz Posted December 2, 2004 Author Report Share Posted December 2, 2004 Nu bet vei.... <?php $conf=array( 1=>array('diagonaale','av_in','av_out'),//tv 2=>array('sound','power','resistance'),//muz.centrs ); $dict=array( 'diagonaale'=>'Diagonāle', 'sound'=>'Skaņa', // utt. ); $q=mysql_query('SELECT * FROM feats LIMIT 20'); while($r=mysql_fetch_assoc($q)) $apply=$conf[$r['cat_id']]; //tiek izveleti kuri lauki jaizvada foreach($apply as $param) echo '<li>'.$dict[$param].': '.(($r[$param]!='')?$r[$param]:'--').'</li>'; ?> Rekur sitaac variants ar iisti negrib iet. ES ATKAL NEREDZU KAUT KAADU FIICHU! :angry: Pac shito skripta fragmentu necepu, taadelj neiebraucu kur vareetu buut kljuuda! :ph34r: Link to comment Share on other sites More sharing options...
bubu Posted December 2, 2004 Report Share Posted December 2, 2004 Kādu kļūdu izvada? un kurā rindiņā? Link to comment Share on other sites More sharing options...
Snukzz Posted December 3, 2004 Author Report Share Posted December 3, 2004 (edited) <? //include($CONF['inc'].'funkcijas.php'); ?> <?php $conf=array( 1=>array('diagonaale','av_in','av_out','skana'),//tv 2=>array('sound','power','resistance'),//muz.centrs ); $dict=array( 'diagonaale'=>'Diagonāle', 'sound'=>'Skaņa', 'av_in'=>'Audio/Video ieeja', 'av_out'=>'Audio/Video izeja', ); $q=mysql_query('SELECT * FROM features LIMIT 20'); while($r=mysql_fetch_assoc($q)) $apply=$conf[$r['cat_id']]; //tiek izveleti kuri lauki jaizvada foreach($apply as $param) echo '<li>'.$dict[$param].': '.(($r[$param]!='')?$r[$param]:'--').'</li>'; ?> Un shis man pretiii... Warning: Invalid argument supplied for foreach() in D:\WEB\ILB\include\feat.php on line 18 :ph34r: Edited December 3, 2004 by Snukzz Link to comment Share on other sites More sharing options...
bubu Posted December 3, 2004 Report Share Posted December 3, 2004 Pārbaudi (ar print_r) vai $apply ir masīvs (to ko padod foreach) Link to comment Share on other sites More sharing options...
Snukzz Posted December 3, 2004 Author Report Share Posted December 3, 2004 ja tas daraas shitaa print_r($apply); tad shis man izmeta (te kaut kaadu jociigu bumbuli, kuru nevar nokopeet) : -- Link to comment Share on other sites More sharing options...
Snukzz Posted December 3, 2004 Author Report Share Posted December 3, 2004 respektiivi vinsh izvada lielo neko... Link to comment Share on other sites More sharing options...
Snukzz Posted December 3, 2004 Author Report Share Posted December 3, 2004 (edited) Aaaaaa.....atradu kaa ir pareizi..:) <?php $feats=array( 1=>array('diagonaale','av_in','av_out','skana'),//tv 2=>array('skana','power','resistance'),//muz.centrs ); $dict=array( 'diagonaale'=>'Diagonāle', 'skana'=>'Skaņa', 'av_in'=>'Audio/Video ieeja', 'av_out'=>'Audio/Video izeja', ); $q=mysql_query('SELECT * FROM features WHERE preces_id='.$prece_id); while($r=mysql_fetch_assoc($q)) $apply=$feats[$r['preces_id']]; //tiek izveleti kuri lauki jaizvada foreach($apply as $param) echo '<li>'.$dict[$param].': '.(($r[$param]!='')?$r[$param]:'--').'</li>'; ?> Vinsh atbildeeja ar Diagonāle: -- Audio/Video ieeja: -- Audio/Video izeja: -- Skaņa: -- Tkai kur lai iemochii skriptu kas paarbauda vai konkreetai precei vispaar ir fiichas un ja nau ta taa ari pasaka??? Un kur lai piespiezj izvadiit arii veertiibas, nevis tikai lauku nosaukumus? Edited December 3, 2004 by Snukzz Link to comment Share on other sites More sharing options...
bubu Posted December 3, 2004 Report Share Posted December 3, 2004 Tev nepareizs ER modelis. Fīčas vajag atdalīt no precēm un likt citā entītē, un starp tām veidod n:n relāciju. Link to comment Share on other sites More sharing options...
Snukzz Posted December 3, 2004 Author Report Share Posted December 3, 2004 nu a man tipa nav... B) Link to comment Share on other sites More sharing options...
john.brown Posted December 3, 2004 Report Share Posted December 3, 2004 Nu bet, ja ir, tad pārbaudi ar mysql_num_rows(), ko tev atgriež selects no features, un atkarībā no tā, taisi foreach(), vai raksti "Fīču nav" :) Un featurēs liec iekšā ierakstu tikai ja fīčas ir. Link to comment Share on other sites More sharing options...
Venom Posted December 3, 2004 Report Share Posted December 3, 2004 if (isset($feats[$r['preces_id']])) $apply=$feats[$r['preces_id']]; else $apply=array(); foreach... Link to comment Share on other sites More sharing options...
Recommended Posts