如果用户的国家/地区不在下拉列表中,则有国家/地区字段存在的注册表单。用户可以选择其他当时显示一个文本框,用户在文本框中输入他们的国家。在用户提交国家之后。如何批准所请求的国家并在php中的国家下拉列表中发布。
的config.php
<?php
$con=mysql_connect("localhost","root","");
if(!$con)
{
die("Could not connect".mysql_error());
}
mysql_select_db("RateMyProfessor",$con);
?>
Demo.php
<?php
include ("config.php");
$query = "select * from user_details where is_approved='0'";
$result=mysql_query($query);
$i = 1; //counter for the checkboxes so that each has a unique name
echo "<form action='process.php' method='post'>"; //form started here
echo "<table border='1'>
<tr>
<th>UserId</th>
<th>Email</th>
<th>Country </th>
<th>Update</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['UserId'] . "</td>";
echo "<td>" . $row['Email'] . "</td>";
echo "<td>" . $row['Country'] . "</td>";
echo "<td><input type='checkbox' name='check[$i]' value='".$row['UserId']."'/>";
echo "</tr>";
$i++;
}
echo "</table>";
echo "<input type='submit' name='approve' value='approve'/>";
echo "</form>";
mysql_close($con);
?>
process.php
<?php
include_once("config.php");
if(isset($_POST['approve']))
{
if(isset($_POST['check']))
{
foreach ($_POST['check'] as $value){
echo $value;
$sql = "update user_details set is_approved ='1' where UserId = '$value'";
mysql_query($sql) or die (mysql_error());
}
}
}
?>
当管理员批准来自管理员国家/地区的国家/地区是国家/地区表格上的副本。
答案 0 :(得分:0)
您可以在批准时在国家/地区表格中插入新记录 例如。
<?php
include_once("config.php");
if(isset($_POST['approve']))
{
if(isset($_POST['check']))
{
foreach ($_POST['check'] as $value){
echo $value;
$sql = "update user_details set is_approved ='1' where UserId = '$value'";
mysql_query($sql) or die (mysql_error());
$sql = "select other_country from user_details where UserId = '$value'";
$result = mysql_query($sql) or die (mysql_error());
if($Other_country_name = mysql_fetch_assoc($result))
{
$Other_country_name = $Other_country_name['other_country'];
}
$sql = "insert into country_table set name = '$Other_country_name'";
mysql_query($sql) or die (mysql_error());
}
}
}
?>
我没有实施条件。请自己动手