Pass variable from href to another php page
. I have this code:
<a id="various3" href="picture.php?id=',$pid,'" title="'.$info.'"><img src="picture.php?id=',$pid,'" width="150" height="210"></a>
it passes the id to my picture.php file, where I use it in the query string.
$sql = sprintf("select pics, ext from `06-07` where id='%d'",$_GET['id']);
Is it possible to pass more than one variable using this method? because I would like to pass "dept" along with "id". if so, then how?
I tried this:
<a id="various3" href="picture.php?id=',$pid,'&dept=',$dept,'" title="'.$info.'"><img src="picture.php?id=',$pid,'&dept=',$dept,'" width="150" height="210"></a>
with matching
$sql = sprintf("select pics, ext from 06-07 where id='%d' AND dept='%s'", $_GET['id'], $_GET['dept']); but it doen't work. what wrong?
+3
4 answers
.
-, .
-, print/echo? , PHP, URL-.
, , , print/echo:
<a id="various3" href="picture.php?id=<?= $pid ?>&dept=<?= $dept ?>" title="<?= $info ?>"><img src="picture.php?id=<?= $pid ?>&dept=<?= $dept ?>" width="150" height="210"></a>
print/echo:
print '<a id="various3" href="picture.php?id='.$pid.'&dept='.$dept.'" title="'.$info.'"><img src="picture.php?id='.$pid.'&dept='.$dept.'" width="150" height="210"></a>';
0