Snukzz Posted December 2, 2004 Report 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:
Venom Posted December 2, 2004 Report Posted December 2, 2004 neredzu nedz foreach, nedz mysql_fetch_* no res4
Venom Posted December 2, 2004 Report Posted December 2, 2004 neredzu nedz foreach, nedz mysql_fetch_*
Snukzz Posted December 2, 2004 Author Report 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:
Snukzz Posted December 3, 2004 Author Report 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
bubu Posted December 3, 2004 Report Posted December 3, 2004 Pārbaudi (ar print_r) vai $apply ir masīvs (to ko padod foreach)
Snukzz Posted December 3, 2004 Author Report Posted December 3, 2004 ja tas daraas shitaa print_r($apply); tad shis man izmeta (te kaut kaadu jociigu bumbuli, kuru nevar nokopeet) : --
Snukzz Posted December 3, 2004 Author Report Posted December 3, 2004 respektiivi vinsh izvada lielo neko...
Snukzz Posted December 3, 2004 Author Report 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
bubu Posted December 3, 2004 Report 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.
john.brown Posted December 3, 2004 Report 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.
Venom Posted December 3, 2004 Report Posted December 3, 2004 if (isset($feats[$r['preces_id']])) $apply=$feats[$r['preces_id']]; else $apply=array(); foreach...
Recommended Posts