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
source share
4 answers
<a href="test.php?page_name=<?php echo $this_month; ?>">

access this page on another page using the get method:

$file_name = $_GET['page_name'];
+8
source

You can chain to get the parameters using the sign and as follows:

index.php?id=1&depth=2
0
source

, get 1 , -

picture.php?id=1&dept=xyx&...

, , , , , .

, ? picture.php?id=',$pid,' picture.php?id=' . $pid . ' picture.php?id=<?php echo $pid; ?> ?

0

.

-, .

-, 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

All Articles