我如何将以下数据仅插入特定用户。例如,从用户名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>";
答案 0 :(得分:0)
根据您的name
列,您可以使用WHERE
子句:
("SELECT * FROM bookings WHERE name='BOB'")
作为一个例子。
或使用变量:
$name = "BOB";
然后做
("SELECT * FROM bookings WHERE name='$name'")