1
0
Fork 0
php-coding/18.test1.php

70 lines
2.4 KiB
PHP

<?php
$mysqli = new mysqli(hostname: 'localhost', username: 'root', password: 'chenx221') or die(mysqli_connect_error());
$mysqli->select_db('db_database18') or die($mysqli->error);
//$stmt = $mysqli->stmt_init();
//$stmt->prepare('insert into tb_member (user,pwd,email) values (?,?,?)');
//$static_param = ['chenx221', 'chenx221', 'chenx221@iloli.one'];
//$stmt->bind_param('sss', $static_param[0], $static_param[1], $static_param[2]);
//$stmt->execute();
//$stmt->affected_rows > 0 ? print 'insert success' : print 'insert fail';
//$stmt->close();
//$stmt = $mysqli->stmt_init();
//$stmt->prepare('update tb_member set user=?,pwd=? where user=?');
//$static_param1 = ['chenx221', 'newpassword'];
//$stmt->bind_param('sss',$static_param1[0],$static_param1[1],$static_param1[0]);
//$stmt->execute();
//$stmt->affected_rows > 0 ? print 'password change success' : print 'password change fail';
//$stmt->close();
//$stmt = $mysqli->stmt_init();
//$stmt->prepare('delete from tb_member where user = ?');
//$static_param2 = ['chenx221'];
//$stmt->bind_param('s',$static_param2[0]);
//$stmt->execute();
//$stmt->affected_rows > 0 ? print 'delete success' : print 'delete fail';
//$stmt->close();
$result = $mysqli->query('select * from tb_member');
echo mysqli_num_rows($result);
echo '<table style="border-collapse: collapse;width: 500px;text-align: center;>';
echo '<tr style="border: 1px solid black"><th>id</th><th>user</th><th>pwd</th><th>email</th></tr>';
//while ($row = $result->fetch_assoc()){
// echo '<tr>';
// echo '<td>'.$row['id'].'</td>';
// echo '<td>'.$row['user'].'</td>';
// echo '<td>'.$row['pwd'].'</td>';
// echo '<td>'.$row['email'].'</td>';
// echo '</tr>';
//}
//while ($row = $result->fetch_object()){
// echo '<tr>';
// echo '<td>'.$row->id.'</td>';
// echo '<td>'.$row->user.'</td>';
// echo '<td>'.$row->pwd.'</td>';
// echo '<td>'.$row->email.'</td>';
// echo '</tr>';
//}
//while ($row = $result->fetch_row()){
// echo '<tr>';
// echo '<td>'.$row[0].'</td>';
// echo '<td>'.$row[1].'</td>';
// echo '<td>'.$row[2].'</td>';
// echo '<td>'.$row[3].'</td>';
// echo '</tr>';
//}
//while ($row = $result->fetch_array()){
// echo '<tr>';
// echo '<td>'.$row[0].'</td>';
// echo '<td>'.$row[1].'</td>';
// echo '<td>'.$row[2].'</td>';
// echo '<td>'.$row[3].'</td>';
// echo '</tr>';
//}
echo '</table>';
$result->free_result();
$mysqli->close();