[英]how to pass a post variable in mysql_fetch_assoc result
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;
}
From $insu2_name = $row[$_POST['insu2']]
; 来自
$insu2_name = $row[$_POST['insu2']]
; I am getting column name, But I want the column Value. 我得到列名,但我想要列Value。 output of
$insu2_name = alp(column name of database)
$insu2_name = alp(column name of database)
输出$insu2_name = alp(column name of database)
Guys help me 伙计们帮助我
Do you know that 你知道吗
select anyRandomSrting from table
will return anyRandomSrting if anyRandomSrting is not a column in the table. 如果anyRandomSrting不是表中的列,则将返回anyRandomSrting。
In your case there will not be a column which name in $_POST['insu2']. 在你的情况下,$ _POST ['insu2']中不会有一个列名。
Update 更新
Check this query once 检查此查询一次
"Select $insu2 from tbl_engineering order by timestamp( `timestamp` ) DESC limit 1"
Please check that i have removed ' from $insu2 请检查我是否已从$ insu2中删除了'
Try changing $insu2_name = $row[$_POST['insu2']];
尝试更改
$insu2_name = $row[$_POST['insu2']];
to $insu2_name = $row['insu2'];
to
$insu2_name = $row['insu2'];
Hope this helps. 希望这可以帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.