Jump to content
php.lv forumi

Recommended Posts

Posted

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:

  • Replies 36
  • Created
  • Last Reply

Top Posters In This Topic

Posted

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:

Posted (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 by Snukzz
Posted

ja tas daraas shitaa print_r($apply);

tad shis man izmeta

 

(te kaut kaadu jociigu bumbuli, kuru nevar nokopeet) : --

Posted (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 by Snukzz
Posted

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.

Posted

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.


×
×
  • Create New...