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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.