Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从MySQL中提取数据并在php中使用表id显示在表中?_Php_Mysql_Sql - Fatal编程技术网

从MySQL中提取数据并在php中使用表id显示在表中?

从MySQL中提取数据并在php中使用表id显示在表中?,php,mysql,sql,Php,Mysql,Sql,有人能告诉我如何使用表的id=“datatable”来显示$output 如果无法回答此问题,请告诉我:是否有任何方法可以使用像“{content}”这样的变量动态显示整个内容。 我该怎么做 这是我的密码: case "user_outgoing_full": $base_url = "index.php?app=menu&inc=user_outgoing&op=user_outgoing_full"; $content = " <h2&

有人能告诉我如何使用表的
id=“datatable”
来显示
$output

如果无法回答此问题,请告诉我:是否有任何方法可以使用像
“{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;
case“user\u outing\u full”:
$base\u url=“index.php?app=menu&inc=user\u outing&op=user\u outing\u full”;
$content=”
传出短信完整报告
时间
到
消息
使现代化
计数
地位
行动
";
if($err=$\u会话['error\u string'])){
回显“$err”;
}
echo$内容;
打破
案例“用户输出完整数据”:
ob_start('ob_gzhandler');
标题('Content type:application/json;charset=UTF-8');
标题('Content Encoding:gzip');
$db_query=“从“\u db_PREF_u.”中选择*。\u tblsmsouting.”其中uid=“.$uid.”和flag_deleted=0按p_msg、p_datetime、uid、flag_deleted分组”;
$db\u result=dba\u查询($db\u查询);
而($db\u row=dba\u fetch\u数组($db\u result)){
$list[]=$db\u行;
}
$j=0;
$maxcount=count($list);
$output=array(
“sEcho”=>intval($\u GET['sEcho']),
“iTotalRecords”=>maxcount美元,
“iTotalDisplayRecords”=>maxcount美元,
“aaData”=>array()
);

对于($j=0;$j您必须使用javascript

这段代码是用javascript库编写的

function newTable(value1,value2){

    $.ajax({
       type:"POST",
       url:"../yourDirectory/your.php",
       data: {var1: value1,
              var2: value2
       },
       success:function(data){
               $("#datatable").html( data ) ;
       } 
   });
}
数据中的代码:{}是php的变量,在您的代码$\u请求[“var1”] 或$u请求[“var2”]。
对于php中的新表,您必须调用函数newTable()

存在一些javascript,通过AJAX将第二个case语句中的数据加载到表中,然后将其放入代码上部输出的表中。