Jump to content
php.lv forumi

mysql_query


voldemarz

Recommended Posts

Nevaru saprast kur seit ir kluuda:

 

$res = mysql_query("select * from readings where '$vakar+24*3600'<unix_timestamp(time) and unix_timestamp(time)<'$vakar+25*3600'");

 

Sitaads variants straadaa:

$res = mysql_query("select * from readings where '$vakar+24*3600'<unix_timestamp(time)");

Link to comment
Share on other sites

Taapeec, ka sitaads variants piemeeram straadaa, nolsa visu liidz tabulas beigaam, saakot ar vajadziigo vietu:

 

$res = mysql_query("select count(*) from readings where unix_timestamp(time)-'$vakar+24*3600'>0");

$sk = mysql_fetch_array($res);

echo "$sk[0]";

 

----------------------------------------------------------------------------------------------------------------------

Bet sitaads, skaitu izvada 0, kaut gan mekleejamajaa intervaalaa ieraksti ir pilniigi noteikti:

 

$res = mysql_query("select count(*) from readings where unix_timestamp(time)-'$vakar+24*3600'>0 and unix_timestamp(time)-'$vakar+25*3600'<0");

$sk = mysql_fetch_array($res);

echo "$sk[0]";

 

 

 

No saakuma meeginaaju sitaa (tas pats, tik savaadaak pierakstiits), bet negaaja, domaaju, ka kaut kaadas sintakses kluudas.

 

$res = mysql_query("select count(*) from readings where '$vakar+24*3600'<unix_timestamp(time) and unix_timestamp(time)<'$vakar+25*3600'");

$sk = mysql_fetch_array($res);

echo "$sk[0]";

Edited by voldemarz
Link to comment
Share on other sites

Saķīlēju ;)

 

Pedinaas taapeec, ka man ieprieks kkur bija taa, ka bez apostrofiem negaaja. Laikam seit:

$res = mysql_query("select * from readings where '$tagad'-unix_timestamp(time)<=$starp");

 

Datbuaazee, tajaa time kolonaa ir datetime tipa mainiigie, eertaak buutu, ja tur buutu timestamp, bet tur neko nevar mainiit. ;)

 

Noneemu sitam peedinas un aizgaaja:

$sk_res = mysql_query("select count(*) from readings where $vakar+24*3600<unix_timestamp(time) and unix_timestamp(time)<$vakar+25*3600 ");

Link to comment
Share on other sites

×
×
  • Create New...