:::

15-1 blocks/new_contact.php

<?php
//顯示最新的通訊錄項目
function new_contact($options){
    global $xoopsDB,$xoopsUser;

    define("_DIR",XOOPS_ROOT_PATH."/uploads/tad_contact");

    $i=0;

    $tbl=$xoopsDB->prefix('contact');
    
    $sql="select * from $tbl order by post_date desc limit 0,{$options[0]}";
    
    
    $result=$xoopsDB->query($sql) or die(mysql_error());
    
    $photo_th=($options[1]=='1')?"<th>相片</th>":"";

    $main="<table border=1  style='width:100%;'>
    <tr>$photo_th<th>姓名</th></tr>";    
    
    while($data=$xoopsDB->fetchArray($result)){    
    
        $color=($i % 2)?"white":"#f0f0f0";
        $i++;
        
        $photo=_DIR."/{$data['sn']}_s.png";
        $show_photo=XOOPS_URL."/uploads/tad_contact/{$data['sn']}_s.png";
        $pic=(file_exists($photo))?"<img src='$show_photo'>":"沒有圖";
        
        $photo_td=($options[1]=='1')?"<td>$pic</td>":"";
        
        $main.= "
        <tr bgcolor='$color'>
            $photo_td
            <td><a href='".XOOPS_URL."/modules/tad_contact/view.php?sn={$data['sn']}'>{$data['name']}</a></td>
        </tr>";
    }
    
    $main.="</table>";
            
    return $main;
}


//編輯最新的通訊錄項目
function new_contact_edit($options){
    
    $checked_0=($options[1]=='0')?"checked":"";
    $checked_1=($options[1]=='1')?"checked":"";

    $main="
    <p>
        秀出幾筆資料?<input type='text' name='options[0]' value='{$options[0]}'>
    </p>
    
    <p>
    是否秀出圖片?
    <input type='radio' name='options[1]' value='0' $checked_0>不秀出
    <input type='radio' name='options[1]' value='1' $checked_1>秀出
    </p>";    
    
    return $main;
}
?>


:::

搜尋

QR Code 區塊

https%3A%2F%2Ftad0616.net%2Fmodules%2Ftad_book3%2Fpage.php%3Ftbsn%3D5%26tbdsn%3D117

書籍目錄

展開 | 闔起

線上使用者

71人線上 (16人在瀏覽線上書籍)

會員: 0

訪客: 71

更多…