2014-03-26 103 views
0

誰能告訴我怎麼表的id="datatable"用於顯示從$output從MySQL中獲取數據並在php中使用表ID顯示在表中?

如果無法回答這個內容,那麼請告訴我:有什麼辦法可以顯示的全部內容動態地使用像" {CONTENT} ".變量

我該怎麼做?

這裏是我的代碼:

case "user_outgoing_full": 
    $base_url = "index.php?app=menu&inc=user_outgoing&op=user_outgoing_full"; 

    $content = " 
     <h2>Outgoing SMS Full Report</h2> 
     <table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" class=\"pretty\" id=\"datatable\" style=\"width:100%;table-layout:fixed\"> 
     <thead> 
     <tr> 
      <th>Time</th> 
      <th>To</th> 
      <th>Message</th> 
      <th>Update</th> 
      <th style=\"width:7%\">Count</th> 
      <th style=\"width:10%\">Status</th> 
      <th style=\"width:10%\">Action</th> 
     </tr> 
     </thead>  
     <thead> 
     <tr> 
      <th></th> 
     </tr> 
     </thead> 
     <tbody> 
     </tbody> 
     </table>"; 
    if ($err = $_SESSION['error_string']) { 
     echo "<div class=error_string>$err</div>"; 
    } 
    echo $content; 
    break; 
case "user_outgoing_full_data": 
     ob_start('ob_gzhandler'); 
    header('Content-type: application/json; charset=UTF-8'); 
    header('Content-Encoding: gzip'); 
    $db_query = "SELECT * FROM "._DB_PREF_."_tblSMSOutgoing"." WHERE uid=".$uid." AND flag_deleted=0 group by p_msg,p_datetime,uid,flag_deleted"; 
    $db_result = dba_query($db_query); 
    while ($db_row = dba_fetch_array($db_result)) { 
     $list[] = $db_row; 
    } 
    $j=0; 
    $maxcount = count($list); 
    $output = array(
    "sEcho" => intval($_GET['sEcho']), 
    "iTotalRecords" => $maxcount, 
    "iTotalDisplayRecords" => $maxcount, 
    "aaData" => array() 
    ); 
    for ($j=0;$j<$maxcount;$j++) { 
     $row = array(); 
     $list[$j] = core_display_data($list[$j]); 
     $smslog_id = $list[$j]['smslog_id']; 
     $c_count=$list[$j]['count']; 
     $p_dst = $list[$j]['p_dst']; 
     $p_desc = phonebook_number2name($p_dst); 
     $current_p_dst = $p_dst; 
     if ($p_desc) { 
      $current_p_dst = "$p_dst<br />$p_desc"; 
     } 
     $p_sms_type = $list[$j]['p_sms_type']; 
     if (($p_footer = $list[$j]['p_footer']) && (($p_sms_type == "text") || ($p_sms_type == "flash"))) { 
      $p_msg = $p_msg.' '.$p_footer; 
     } 
     $p_datetime = core_display_datetime($list[$j]['p_datetime']); 
     $p_update = core_display_datetime($list[$j]['p_update']); 
     $p_status = $list[$j]['p_status']; 
     $p_gpid = $list[$j]['p_gpid']; 
     // 0 = pending 
     // 1 = sent 
     // 2 = failed 
     // 3 = delivered 
     // 4 = DND 
     /*if ($p_status == "1") { 
      $p_status = "<span class=status_sent />"; 
     } else if ($p_status == "2") { 
      $p_status = "<span class=status_failed />"; 
     } else if ($p_status == "3") { 
      $p_status = "<span class=status_delivered />"; 
     } else { 
      $p_status = "<span class=status_pending />"; 
     } 
     $p_status = strtolower($p_status);*/ 
     if ($p_status == "1") { 
      $p_status = "SENT"; 
     } else if ($p_status == "2") { 
      $p_status = "FAILED"; 
     } else if ($p_status == "3") { 
      $p_status = "DELIVERED"; 
     } else if ($p_status == "4") { 
      $p_status = "DND"; 
     } else { 
      $p_status = "PENDING"; 
     } 
     if ($p_gpid) { 
      $p_gpcode = strtoupper(phonebook_groupid2code($p_gpid)); 
     } else { 
      $p_gpcode = "&nbsp;"; 
     } 
     $msg = $list[$j]['p_msg']; 
     $p_msg = core_display_text($msg); 
     if ($msg && $p_dst) { 
      $resend = _a('index.php?app=menu&inc=send_sms&op=sendsmstopv&do=reply&message='.urlencode($msg).'&to='.urlencode($p_dst), $core_config['icon']['resend']); 
      $forward = _a('index.php?app=menu&inc=send_sms&op=sendsmstopv&do=forward&message='.urlencode($msg), $core_config['icon']['forward']); 
     } 
     $c_option = $resend."&nbsp".$forward; 

     $row[] = $p_datetime; 
     $row[] = $current_p_dst; 
     $row[] = $p_msg; 
     $row[] = $p_update; 
     $row[] = $c_count; 
     $row[] = $p_status; 
     $row[]= $c_option; 
     $output['aaData'][] = $row; 
    } 
    echo json_encode($output); 
    exit(); 
    break; 
+1

存在一些JavaScript通過AJAX加載第二個case語句中的數據,並將其放到代碼上半部分輸出的表中。 – GhostGambler

回答

0

你必須使用JavaScript

此代碼是jquery,JavaScript庫

function newTable(value1,value2){ 

    $.ajax({ 
     type:"POST", 
     url:"../yourDirectory/your.php", 
     data: {var1: value1, 
       var2: value2 
     }, 
     success:function(data){ 
       $("#datatable").html(data) ; 
     } 
    }); 
} 

裏面的代碼數據:{}是變量對於PHP,在您的代碼$ _REQUEST [「var1」] 或$ _REQUEST [「var2」]。 對於PHP的新表,你必須調用函數newTable()

相關問題