Jump to content
php.lv forumi

viens zem otra...


Snukzz

Recommended Posts

  • Replies 51
  • Created
  • Last Reply

Top Posters In This Topic

Nu cilvēki -programētāji, grāmatveži - ... da jebkas, nu palīdziet man! Es savādāk tulīt kritīšu iz-mis-sumā! :( Nu vaig man lai tas skripc strādā! paluriet..plz...plz! :huh: Es saslimis un došos čučēt, bet kad atnākšu možkad skriptu ieraudzīšu! ;)

Link to comment
Share on other sites

Uzchiniiju!:) bet kaut kas neiet, nesaprotu IF ciklu! Kuraa vietaa man jaaiekodee tas, ka JA kverijs ir tuksh TAD izvadaas tas ja nee raadam kverija rezultaatu

<?
include($CONF['inc'].'funkcijas.php');
?>
<TABLE cellpadding=0 cellspacing=0>
<?
$sub_kat_id=user_num($_GET['skatid']);
$res=mysql_query('SELECT nos, art, kat_id, sub_kat_id, id, stock FROM preces WHERE stock = 1 && sub_kat_id='.$sub_kat_id);
{
while($row=mysql_fetch_row($res)){ 
?>
<TR><TD><A href="./?page=8&prece=<?=$row[4] ?>"><?=$row[1] ?> - <?=$row[0] ?></A></TD></TR>
<?

if (empty($res)){ echo "Nav prechu";}}}
?>

<TR><TD><script LANGUAGE="JavaScript">function goHist(a){ history.go(a);}</script>
<FORM METHOD="post">
<INPUT TYPE="button" VALUE="  BACK " onClick="goHist(-1)">
</form>
</TD></TR>
</TABLE>

Link to comment
Share on other sites

$res=mysql_query('SELECT ...');
if (!$res || !@mysql_affected_rows($res))
{
_echo 'Nekā nav';
}
else
_while($row=mysql_fetch_row($res))
_{
__echo print_r($row,1);
_}

 

iemācies pareizi identēt (noformēt ar atstarpēm) kodu, vai vismaz izmanto editoru, kurš iekrāso pāra iekavas, tad arī nesaputrosies ifos/ciklos

 

citādi tev iekš koda lieks { pirms while iraid

Link to comment
Share on other sites

Nu... sitaa buus pareizi?

<TABLE cellpadding=0 cellspacing=0>
<?
if (!$res || !@mysql_affected_rows($res))
{
echo 'Neka nav';
}
else
while($row=mysql_fetch_row($res))
{
 ?>
<TR><TD><A href="./?page=8&prece=<?=$row[4] ?>"><?=$row[1] ?> - <?=$row[0] ?></A></TD></TR>
<?
}
?>
<TR><TD><script LANGUAGE="JavaScript">function goHist(a){ history.go(a);}</script>
<FORM METHOD="post">
<INPUT TYPE="button" VALUE="  BACK " onClick="goHist(-1)">
</form>
</TD></TR>
</TABLE>

kaut kaa visu laiku izvada ka nekaa nav!

Edited by Snukzz
Link to comment
Share on other sites

Nu ja... :(..... kaut gan ... kverijs bija sitaads

$res=mysql_query('SELECT nos, art, kat_id, sub_kat_id, id, stock FROM preces WHERE stock = 1 && sub_kat_id='.$sub_kat_id);

Edited by Snukzz
Link to comment
Share on other sites

Klau gjeeniji, palabojiet mani, nemaaku gramatiku! :P

<TABLE cellpadding=0 cellspacing=0>
<?
include($CONF['inc'].'funkcijas.php');
?><TR>
<?
$res2=mysql_query('SELECT id, nos FROM brendi);
while($row2=mysql_fetch_row($res2)){ 
?>
<TD><A href="./?page=15&list=<?=$row2[0] ?>"><?=$row2[1] ?></A></TD>
<?
}
?>
</TR>
<?
$sub_kat_id=user_num($_GET['skatid']);
$res=mysql_query('SELECT nos, art, kat_id, sub_kat_id, id, stock FROM preces WHERE stock = 1 && sub_kat_id='.$sub_kat_id);
while($row=mysql_fetch_row($res)){ 
?>
<TR><TD><A href="./?page=8&prece=<?=$row[4] ?>"><?=$row[1] ?> - <?=$row[0] ?></A></TD></TR>
<?
if (empty($res)){ echo "Nav prechu";}}
?>

<TR><TD><a href="#" onClick="history.go(-1)"><-Atpakaļ</a>
</TD></TR>
</TABLE>

Link to comment
Share on other sites

ieliec pašā sākumā, tur, kur pirmais <? (vai pat vēlams, lai tas būtu <?php)

error_reporting(E_ALL);

 

$res2=mysql_query('SELECT id, nos FROM brendi');

 

iekš mysql && zīmei ir mazliet citādāka nozīme, loģiskiem apvienojumiem pierasts lietot AND

 

while($row=mysql_fetch_row($res)){ 
?>
<TR><TD><A href="./?page=8&prece=<?=$row[4] ?>"><?=$row[1] ?> - <?=$row[0] ?></A></TD></TR>
<?
if (empty($res)){ echo "Nav prechu";}}
?>

 

un kas šeit notiek?

nu protams, ka izvadīsies, ka nav preču, jo ar fetch_row viss arī būs izzīsts

 

if (empty($res))
echo "Nav prechu";
else
while($row=mysql_fetch_row($res))
{ ?>
<TR><TD><A href="./?page=8&prece=<?=$row[4] ?>"><?=$row[1] ?> - <?=$row[0] ?></A></TD></TR>
<? }
?>

Link to comment
Share on other sites


×
×
  • Create New...