if($_POST)
{
$client = $_POST['client'];
$insu1 = $_POST['insu1'];
$insu2 = $_POST['insu2'];
$date = date("dmY");
if($insu2 = 'alp' or $insu2='bppi' or $insu2='cpmp' or $insu2='carp' or $insu2='dsp' or $insu2='eep' or $insu2='earp' or $insu2='mbp')
{
//set @insu2 = $insu2;
$sql2 ="Select '$insu2' from tbl_engineering order by timestamp( `timestamp` ) DESC limit 1 ";
$result2=mysql_query($sql2);
//$insu2_name ='';
var_dump($result2);
while($row = mysql_fetch_assoc($result2))
{
echo $insu2;
var_dump($row);
$insu2_name = $row[$_POST['insu2']];
echo $insu2_name;
}
来自$insu2_name = $row[$_POST['insu2']]
;我得到列名,但我想要列Value。
输出$insu2_name = alp(column name of database)
伙计们帮助我
答案 0 :(得分:2)
你知道吗
"Select $insu2 from tbl_engineering order by timestamp( `timestamp` ) DESC limit 1"
如果 anyRandomSrting 不是表格中的列,将返回anyRandomSrting。
在您的情况下,$ _POST [' insu2']中不会有一个名称列。
<强>更新强>
检查此查询一次
@PersistenceContext(unitName = "my-pu")
private EntityManager em;
@Override
public void removeUserFromGroup(String username, Group group) {
Query query = em.createNamedQuery("Group.getByName", Group.class);
query.setParameter("name", group.getGroupName());
Group qGroup = (Group) query.getSingleResult();
// this works
// Iterator<User> i = qGroup.getUsers().iterator();
// while (i.hasNext()) {
// User o = i.next();
// if (o.getUsername().equals(username)) {
// System.out.println("eqqq");
// i.remove();
// }
// }
System.out.println("class: " + qGroup.getUsers().getClass().getName());
// org.eclipse.persistence.indirection.IndirectList
qGroup.getUsers().removeIf(u -> u.getUsername().equals(username));// doesn't work
}
请检查我是否删除了&#39;来自$ insu2
答案 1 :(得分:0)
尝试将$insu2_name = $row[$_POST['insu2']];
更改为$insu2_name = $row['insu2'];
希望这有帮助。