/    Sign up×
Community /Pin to ProfileBookmark

simpel <ahref> php question

Hi what I have is this simpel script on a page called pop1.php:

[code=php]
<?php

$idNew = “2”;
echo ($idNew);

?>
[/code]

I have another page called pop2.php which has a button with a link to:

pop1.php?idNew=idNew + “8”;

What this link should do is giving an echo in pop1.php of $idNew and the echo should be: “28”

How is this possible??

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@creatorNov 18.2004 — I'm not sure I undserstad you correctly but try this:

Your URL: pop1.php?idNew=8

I'm not sure the you can use URL parameters in the way you do.

So i'm plying it safe. And if you need to combine to number and not add them togeter, use the concatinate them.

Inside pop1.php

[code=php]
<?php
$idNew = "2".$_GET['idNew'];
echo $idNew;
?>
[/code]
Copy linkTweet thisAlerts:
@goebNov 18.2004 — if you have :

<a href='pop1.php?idNew=idNew + "8";'>

then in pop1.php, the value of $idNew will be :

- either the string 'idNew'

- or the string 'idNew + "8";'

(depending on the browser I suppose)

In no case you will get what you expect.
Copy linkTweet thisAlerts:
@NogDogNov 19.2004 — [code=php]
$idNew = 2;
$url = urlencode(sprintf("idNew=%d8", $idNew));
echo "<a href='pop1.php?$url'>";
[/code]
×

Success!

Help @zebdaag spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...