Jump to content

Using variables in <a href>


chomedey

Recommended Posts

Hello all,

 

This is my first posting to this forum.

 

Can anyone tell me what is wrong with this code and how to make it right.

 

echo '<p><a href="my_deepshares.php?ln=$limit_number+10>Next 10</a></p>';

 

I am wanting to get 10 more entries from an SQL table each time the user hits "more" and have set up a variable called $limit_number that is then used in the SQL query.  But when I try to pass the $limit_number variable plus 10 in the URL to the same page it won't substitute the variable number for the variable name.  So I end up with my_deepshares.php?ln=$limit_number in the sent URL instead of ln=10 (say).  I have tried every kind of bracketing and quote permutation I can think of - and still no luck.

 

Any help much appreciated.

 

Cheers.

Link to comment
https://forums.phpfreaks.com/topic/190961-using-variables-in/
Share on other sites

its quite simple really, you're using single quotes, which DO NOT evaluate variables.. use double quotes (")

 

OK, thanks, that works for the variable.  Now is there any way of adding 10 to the variable within the href or do I have to change the variable before I use it?

Thanks again.

Julian

Link to comment
https://forums.phpfreaks.com/topic/190961-using-variables-in/#findComment-1007004
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.