我正在为我公司的销售构建基于php的Web应用程序。 我正在创建一种功能,使销售人员能够将他的客户放入列表中以评估他的行为。 所以我有一个客户的屏幕,每行我都有一个下拉菜单显示:
我的问题是选项c: 我在下拉列表中创建了一个表单,以便为新列表名称提供输入。代码适用于除第一个以外的所有行! 我的代码是:
/// check if the customer belong to a list
$query1 = "SELECT `cust_fav_type` FROM `customers_favorites` WHERE cust_fav_fs_id = '{$customer_fs_id}' AND cust_fav_user_id='{$_SESSION['user_id']}' ";
$select_cb_lists = mysqli_query($connection,$query1);
if(mysqli_num_rows($select_cb_lists)){
$count = mysqli_num_rows($select_cb_lists);
/// if he exists I m creating a link with remove ability
?>
<td class="text-center">
<div class="dropdown">
<h4>
<button class="btn btn-info dropdown-toggle btn-xs" type="button" data-toggle="dropdown"> <b><?php echo $count;?></b>
<span class="caret"></span></button>
<ul class="dropdown-menu dropdown-menu-right">
<?php
while($row=mysqli_fetch_assoc($select_cb_lists)){
$c_list = $row['cust_fav_type'];
echo "<li><a href='posts.php?source=posts_list&cust_fs_id=$customer_fs_id&removefromlist=$c_list' onClick=\"javascript: return confirm('Σιγουρα θες να αφαιρέσεις τον $customer_name απο την λίστα $c_list?'); \"> <b>$c_list</b> <i class='text-danger'><span class='glyphicon glyphicon-remove'></span></i></a></li>";
}
/// ...and the ability to add to an existing list..
$query = "SELECT ul.cust_fav_type FROM users_lists ul LEFT JOIN (SELECT `cust_fav_type` FROM `customers_favorites` WHERE cust_fav_fs_id = '{$customer_fs_id}' AND cust_fav_user_id='{$_SESSION['user_id']}') as a ON ul.`cust_fav_type` =a.`cust_fav_type` WHERE ul.`cust_fav_user_id`='{$_SESSION['user_id']}' AND a.cust_fav_type IS NULL ";
$other_lists = mysqli_query($connection,$query);
if(mysqli_num_rows($other_lists)){
echo "<li class='divider'></li> ";
while($row=mysqli_fetch_assoc($other_lists)){
$list_name = $row['cust_fav_type'];
echo "<li><a href='posts.php?source=posts_list&cust_fs_id=$customer_fs_id&addto=$list_name'>Προσθηκη σε <b>$list_name</b></a> </li> ";
}
}
?>
<br>
/// THE Problem!! a form for inserting customer to a new list
<li>
<form action="posts.php" method="get">
<div class="input-group">
<input class="form-control" type="hidden" name="source" value="posts_list">
<input type="hidden" name="cust_fs_id" value="<?php echo $customer_fs_id;?>">
<input class="form-control" type="text" name="addto" placeholder="Προσθηκη σε νεα λίστα">
<span class='input-group-btn'>
<button class='btn btn-primary' type="submit"><span class='glyphicon glyphicon-plus'></span></button></span>
</div>
</form>
</li>
</ul>
</h4>
</div>
</td>
<?php
} else {
$count = "-";
?>
<td class="text-center">
<div class="dropdown"><h4>
<button class="btn btn-primary dropdown-toggle btn-xs" type="button" data-toggle="dropdown"><span class='glyphicon glyphicon-plus'></span><span class="caret"></span></button>
<ul class="dropdown-menu dropdown-menu-right">
<?php
$query = "SELECT cust_fav_type FROM customers_favorites ";
$query .= " WHERE cust_fav_user_id={$_SESSION['user_id']} ";
$query .= "GROUP BY cust_fav_type ORDER BY cust_fav_type ";
$select_customers_cities = mysqli_query($connection,$query);
while($row = mysqli_fetch_assoc($select_customers_cities)) {
$customers_filters = $row['cust_fav_type'];
echo "<li><a href='posts.php?source=posts_list&cust_fs_id=$customer_fs_id&addto=$customers_filters'>Προσθήκη σε <b>$customers_filters</b></a></li>";
}
?>
</ul>
</h4>
</div>
</td>
<?php } ?>
正如我写的那样,除了第一个以外,所有客户都能正常工作! 任何帮助都会有价值!
感谢名单!