Use el formato html, llame a la base de datos a través de php y muestre los datos

Continuación del artículo anterior    https://blog.csdn.net/mainmaster/article/details/114686335?spm=1001.2014.3001.5501

<! DOCTYPE html>
<html ng-app = 'prueba'>

<head>
    <meta charset = "UTF-8">
    <meta http-equiv = "Content-type = text / html; charset = utf-8" />
    <! - jQuery ->
    <script type = "text / javascript "src =" http://code.changer.hk/jquery/1.11.2/jquery.min.js "> </script>
     <! - CSS más reciente compilado y minimizado ->
    <link rel =" hoja de estilo "href =" https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css "Integrity =" sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va + PmSTsz / K68vbd = crossEjin4
    style < "texto / css">
        .table {             ancho: 1000px;             alineación de texto: centro;





<body ng-controller = 'main'>
    <div class = "">
        <center>
        <table class = "table table-
            bordered table-striped"> <thead>
                <tr>
                    <td> 学 号 </td>
                    < td> 姓 </td>
                    <td> 名 </td>
                    <td> 邮件 地址 </td>                    
                </tr>
            </thead>
            <tbody id = "tbody"> </tbody>
        </table>
        </ centro>
    </div>
</body>
<script type = "texto / javascript ">
//"{"id":"1","firstname":"John","lastname":"Doe","email":"[email protected]"}{"id":"2 "," firstname ":" Mary "," lastname ":" Moe "," email ":" [email protected] "} {" id ":" 3 "," firstname ":" Julie "," lastname ":" Dooley "," email ":" [email protected] "} {" id ":" 4 "," firstname ":" John "," lastname ":" Doe "," email ":" [email protected] " } {"id": "5", "firstname": "Mary", "lastname": "Moe", "email": "[email protected]"} {"id": "6", "firstname" : "Julie", "lastname ":" Dooley "," email ":" [email protected] "} {" id ":" 7 "," firstname ":" John "," lastname ":" Doe "," email ":" john @ example.com "} {" id ":" 8 "," firstname ":" Mary "," lastname ":" Moe "," email ":" [email protected] "} {" id ":" 9 "," firstname ":" Julie "," lastname ":" Dooley "," email ":" [email protected] "} {" id ":" 10 "," firstname ":" John "," lastname " : "Doe", "email": "[email protected]"} {"id": "11", "firstname": "Mary", "lastname": "Moe", "email": "mary @ example .com "} {"id": "12", "firstname": "Julie", "lastname": "Dooley", "email": "[email protected]"} "
reemplazar('{','');             trStr + = '<tr class = "ejemplo">';            














            trStr + = '<td width = "15%">' + JSON.parse (a [i]). id + '</td>';
            trStr + = '<td width = "15%">' + JSON.parse (a [i]). firstname + '</td>';
            trStr + = '<td width = "15%">' + JSON.parse (a [i]). lastname + '</td>';
            trStr + = '<td>' + JSON.parse (a [i]). email + '</td>';
            // trStr + = '<td>' + JSON.parse (a [i]). reg_date + '</td>';
            trStr + = '</tr>';  
        } 
        $ ("# tbody"). html (trStr); 
    }
});
</script>
</html>

La interfaz de ejecución es como se muestra a continuación

Se usa un método muy tonto para leer datos en un bucle. Al principio, no he descubierto cómo dividir el objeto json que contiene múltiples registros de datos. ¿Alguien puede darme una idea, gracias?

Supongo que te gusta

Origin blog.csdn.net/mainmaster/article/details/114823740
Recomendado
Clasificación