PHP:如何从mysql检索数据并插入到特定用户

标签 php mysql database insert

我如何将以下数据仅插入到特定用户。例如,用户名 Ben 和密码“cardboard”。

 <?php
      // Connects to your Database 
     mysql_connect("blank.blank.ac.uk", "", "") or die(mysql_error()); 
     mysql_select_db("dbBolives") or die(mysql_error()); 
     $data = mysql_query("SELECT * FROM bookings") 
     or die(mysql_error()); 
     Print "<table border cellpadding=3>"; 
     while($info = mysql_fetch_array( $data )) 
     { 
     Print "<tr>"; 
     Print "<th>id:</th> <td>".$info['id'] . "</td> "; 
     Print "<th>date:</th> <td>".$info['date'] . " </td></tr>"; 
     Print "<th>start:</th> <td>".$info['start'] . "</td> "; 
     Print "<th>name:</th> <td>".$info['name'] . " </td></tr>"; 
     Print "<th>email:</th> <td>".$info['email'] . "</td> "; 
     Print "<th>phone:</th> <td>".$info['phone'] . " </td></tr>"; 
     Print "<th>comments:</th> <td>".$info['comments'] . " </td></tr>"; 
     } 
     Print "</table>"; 

最佳答案

根据您的 name 列,您可以使用 WHERE 子句:

("SELECT * FROM bookings WHERE name='BOB'")

举个例子。

或者使用变量:

$name = "BOB";

然后做

("SELECT * FROM bookings WHERE name='$name'")

关于PHP:如何从mysql检索数据并插入到特定用户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22612919/

相关文章:

php - 在 PHP 中将大整数转换为完整字符串

mysql - CakePHP 3 : HasOne relation throws SQLSTATE[23000]: 1048 Column 'id' cannot be null

sql - 在 postgresql 中四舍五入列值

mysql - Mysql中的游标除了用户还有其他权限吗?

php - 用于 PHP 的 jTables 过滤

php - setAttribute/addAttribute 中的 XML 实体

mysql - 从 rails 中的另一个对象创建一个对象

MySQL - 按行的底部 (X) 百分比限制

java - 如何在查看寻呼机中的图像顶部添加文本?

php - Wamp Server 3.0.8图标托盘右键菜单不一样