Jump to content

Recommended Posts

I have a url link that is fetch from a mysql database.

$id=5;

$link->link_url="details.php?id={$id}";
echo $link->link;

output:
   details.php?id={$id}

I need it to output:
   details.php?id=5

How can I do this?
 

I need the url link so I can use it in different area of the website.

Any help will be greatly appreciated!

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/315614-need-help-coding-php/
Share on other sites

This code:

$link->link_url="details.php?id={$id}";
echo $link->link;

Why is it like that?  If you don't want to output something with braces in it, why do you assign the braces to it?

And if you are making an assignment to a class var named 'link_url' why then do you output a var named 'link'?

And if that url value is truly coming from a mysql database, why not update your database entry?

10 hours ago, rick_8040 said:

I have a url link that is fetch from a mysql database.

Is stored in mysql database as "details.php?id={$id}"

$id=5;

$link->link_url="details.php?id={$id}";
echo "<li><a href='".$link->link_url."' title="">".$link->)link_name."</a></li>";

output:
 echo "<li><a href='"details.php?id={id}"' title=''>".$link->)link_name."</a></li>";

 

I need it to output:

 echo "<li><a href='"details.php?id=5"' title=''>".$link->)link_name."</a></li>";


   details.php?id=5

How can I do this?
 

I need the url link so I can use it in different area of the website.

Any help will be greatly appreciated!

 

 

 

 

11 hours ago, Barand said:

Are you sure that is your actual code?

I ask because your output is showing the symptoms of using single quotes around the string instead of double quotes. That is

$link->link_url='details.php?id={$id}'; 

intead of

$link->link_url="details.php?id={$id}"; 

 

Your last post makes no sense at all.  You can't write code that looks like that.

Why are you storing this supposed code in a database table?  Why not just write it?  Why include braces in it when they are clearly not needed?

As Barand has already said it appears that your supposed php code may be stored or retrieved through single quotes and not double ones, thus it does not get translated the way you want.

So - what is our point in storing code in a table since you are clearly a noob at coding?

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.