使用 img src url 传递多个 php 变量

Passing multiple php variable using img src url

我是 PHP 的新手。创建具有多个页面的应用程序。

Sample1.php

$queue=$_POST['element_3'];//Customer name
$month=(int)$_POST['month'];//month as value 06
$std_yy = $_POST['year'];// 2016
<img src="trend_g.php?element_3=$queue&month=$std_mm&year=$std_yy" /> //does not work
<img src="trend_g.php?element_3=Apple&month=06&year=2016" />//works

trend_g.php

$queue=$_GET['element_3'];
$month=(int)$_GET['month'];
$std_yy = $_GET['year'];

请帮我把变量传给URL。我也尝试了下面的方法。

<img src="trend_g.php?element_3='.$queue.'&month='.$std_mm.'&year='.$std_yy.'" /> //didnt work.

查看了各种选项,但我被困在这里。非常感谢任何帮助!

当仍在 PHP 中时,您没有将 img 元素称为 PHP,即在结束 PHP 标记之前 (?>)

改变

<img src="trend_g.php?element_3=$queue&month=$std_mm&year=$std_yy" />

<img src="trend_g.php?element_3=Apple&month=06&year=2016" />

echo '<img src="trend_g.php?element_3='.$queue.'&month='.$std_mm.'&year='.$std_yy.'" /> ';

echo '<img src="trend_g.php?element_3=Apple&month=06&year=2016" />';

编辑

如果您确实关闭了 php,那么您需要更改

<img src="trend_g.php?element_3=$queue&month=$std_mm&year=$std_yy" />

<img src="trend_g.php?element_3=<?php echo $queue;?>&month=<?php echo $std_mm;?>&year=<?php echo $std_yy;?>" />