PHP:如何从mysql检索数据并插入特定用户(PHP: How to retrieve data from mysql and insert to specific user)
我将如何将以下数据仅插入特定用户。 例如,从用户名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>";How would i go about inserting the data below to a specific user only. for example, from the username Ben and his password "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'")Based on your name column, you could use a WHERE clause:
("SELECT * FROM bookings WHERE name='BOB'")as an example.
Or use a variable:
$name = "BOB";then do
("SELECT * FROM bookings WHERE name='$name'")更多推荐
Print,$info,th>,<td>,电脑培训,计算机培训,IT培训"/> <meta name="
发布评论