private function getRandomQuote() { $today = date('Y-m-d'); //今天日期 $result = TbaBoard::model()->findAllByAttributes(array(), $conditon = "datee >='{$today}' and opt1=1 and opt2=1 "); $quote = $result[array_rand($result, 1)]; return $quote; }
<div class="tableBlue"> <!--tableBlue --> <?php echo CHtml::beginForm(); ?> <table > <tr> <td ><?php echo TbaBoard::model()->getAttributeLabel('dates'); ?> </td> <td><?php echo TbaBoard::model()->getAttributeLabel('title'); ?> </td> </tr> <?php for ($i = 0; $i < count($result); $i++) { echo "<tr>"; echo "<td td width= 200px>"; echo $result[$i]['dates']; echo "</td>"; echo "<td>"; echo CHtml::link($result[$i]['read'] ? $result[$i]['title'] : "<b>" . $result[$i]['title'] . "</b>", array('tbaBoard/empread?id=' . $result[$i]['id']), array('target' => '_self')); echo "</td>"; echo "</tr>"; }
for ($i = 0; $i < count($result); $i++) { echo "<tr>"; echo "<td>"; echo "<b>#-</b> " . CHtml::link($result[$i]['read'] ? $result[$i]['title'] : "<b>" . $result[$i]['title'] . "</b>", array('tbaBoard/empread?id=' . $result[$i]['id']), array('target' => '_self')); echo "</td>"; echo "</tr>"; } ?> </table> </td> <td > <?php $homepicture = TbaBoard::model()->findByAttributes(array(), $conditon = " datee >='{$today}'and opt3 = 1 order by datee desc"); if ($homepicture) { echo CHtml::image(Yii::app()->request->baseUrl . $homepicture->imageurl . '.' . $homepicture->imagetype, 'show no picture', array("width" => "350px", "height" => "280px")); } ?> </td> </tr> </table> <?php echo CHtml::endForm();