haq 0 Report post Posted June 25, 2012 Сайт: http://ruwarez.tk <?php $res = $db->query("SELECT sizefiles FROM ".PREFIX."_post where id = '{$news_id}'"); if ($db->num_rows($res) > 0) { $sizefiles = $db->super_query("SELECT sizefiles as sizefiles FROM ".PREFIX."_post WHERE id='{$news_id}'"); $sizefiles = $sizefiles['sizefiles']; echo "$sizefiles"; } else { echo "Тра та та"; } ?> Скрипт должен выводить "Тра та та" если в таблице 0, а если больше ноля, то значение из таблицы, почему даже если у меня в таблице 0, то всё равно выводится значение из таблицы? Помогите пожалуйста исправить Quote Share this post Link to post Share on other sites
Old_chekist 4 Report post Posted June 26, 2012 (edited) а в таблице _post есть sizefiles? чё за бред sizefiles as sizefiles у меня так работает $res = $db->query("SELECT date FROM ".PREFIX."_post where id = '{$news_id}'"); if ($db->num_rows($res)) { $sizefiles = $db->super_query("SELECT date FROM ".PREFIX."_post WHERE id='{$news_id}'"); $sizefiles = $sizefiles['date']; echo $sizefiles; } else { echo "Тра та та"; } Edited June 26, 2012 by Old_chekist 1 Quote Share this post Link to post Share on other sites
a1ex 60 Report post Posted June 26, 2012 (edited) прости за выражение - насрать наруки. $sizefiles = $db->super_query("SELECT date FROM ".PREFIX."_post WHERE id='{$news_id}'"); echo (isset($sizefiles['date'])?$sizefiles['date']:"Тра та та"); Edited June 26, 2012 by a1ex 1 Quote Share this post Link to post Share on other sites
haq 0 Report post Posted June 26, 2012 Спасибо, но не работает (А зачем вы заменили "SELECT sizefiles" на "SELECT date" если выводить мне надо не дату, а значение sizefiles ?) a1ex, ваш вариант тоже не работает, теперь постоянно выводит "тра та та" в независимости пустое ли поле sizefiles или там что-то есть Надо сделать если в таблице в sizefiles что-то есть, то это значение выводится, а если пусто, то выводится сообщение "тра та та" Quote Share this post Link to post Share on other sites
Sarvan 35 Report post Posted June 26, 2012 $res = $db->query("SELECT sizefiles FROM ".PREFIX."_post where id = '{$news_id}'"); if ($db->num_rows($res) > 0) { $sizefiles = $db->super_query("SELECT sizefiles FROM ".PREFIX."_post WHERE id='{$news_id}'"); echo ($sizefiles['sizefiles'] == 0 OR $sizefiles['sizefiles'] == "") ? "Тра та та" : $sizefiles['sizefiles']; } else { echo "Тра та та"; } 1 Quote Share this post Link to post Share on other sites
haq 0 Report post Posted June 26, 2012 Спасибо огромное, всё работает, а тут что нету кнопки "спасибо" Quote Share this post Link to post Share on other sites
WWW.ZEOS.IN 1,160 Report post Posted June 26, 2012 haq, есть 1 Quote Share this post Link to post Share on other sites
haq 0 Report post Posted June 26, 2012 Последний вопрос, а как сделать, что бы вместо "Тра та та" можно было бы выполнить какой-либо скрипт? Quote Share this post Link to post Share on other sites
Sarvan 35 Report post Posted June 26, 2012 (edited) echo ($sizefiles['sizefiles'] == 0 OR $sizefiles['sizefiles'] == "") ? "Тра та та" : $sizefiles['sizefiles']; на if ($sizefiles['sizefiles'] == 0 OR $sizefiles['sizefiles'] == "") { echo "Тра та та"; } else { echo $sizefiles['sizefiles']; }[/code] Edited June 26, 2012 by Sarvan 1 Quote Share this post Link to post Share on other sites
WWW.ZEOS.IN 1,160 Report post Posted June 26, 2012 (edited) $res = $db->query("SELECT sizefiles FROM ".PREFIX."_post where id = '{$news_id}'"); if ($db->num_rows($res) > 0) { $sizefiles = $db->super_query("SELECT sizefiles FROM ".PREFIX."_post WHERE id='{$news_id}'"); if( $sizefiles['sizefiles'] == 0 OR $sizefiles['sizefiles'] == "" ) { //тут код скрипта } else { echo $sizefiles['sizefiles']; } } else { //тут код скрипта } Пока писал, меня уже опередили Edited June 26, 2012 by WWW.ZEOS.IN 1 Quote Share this post Link to post Share on other sites
haq 0 Report post Posted June 26, 2012 Огромное спасибо за помощь, кстати как вы изучали php ? Какими источниками пользовались? Quote Share this post Link to post Share on other sites
a1ex 60 Report post Posted June 27, 2012 $sizefiles = $db->super_query("SELECT date FROM ".PREFIX."_post WHERE id='{$news_id}'"); echo ((isset($sizefiles['date']) and $sizefiles['date']!='' and intval($sizefiles['date'])!=0)?$sizefiles['date']:"Тра та та"); Зачем делать 2 запроса? что за бред?? 1 Quote Share this post Link to post Share on other sites
Adobe 110 Report post Posted June 27, 2012 Огромное спасибо за помощь, кстати как вы изучали php ? Какими источниками пользовались? php.net там есть все что нужно. 1 Quote Share this post Link to post Share on other sites