Jump to content

Part of a url contains data from a MySQL field... possible?


mattc_uk

Recommended Posts

Is is possible to write php code whereby it will contain a url but part of the url address is extracted from a MySQL database field? What would be the right coding for this?

 

i.e.

 
print "<a href=\"http://www.mysite.com/....  ['database field name']... /more of url address\"</a>"

 

 

Link to comment
Share on other sites

echo '"www.google.com/".$your_field_from_database."therestofyoururl.com"';

Because you have single quotes around the whole thing, that won't work.

 

echo "www.google.com/{$your_field_from_database}therestofyoururl.com"

 

Would work and remove the concatenation.

Or use single quotes and concat.

 

 

OP, if you're stuck post actual code.

Link to comment
Share on other sites

 

Because you have single quotes around the whole thing, that won't work.

 

echo "www.google.com/{$your_field_from_database}therestofyoururl.com"

 

Would work and remove the concatenation.

Or use single quotes and concat.

 

Oops, right you are. Simply remove the single quotes so it becomes:

 

echo "www.google.com/".$your_field_from_database."therestofyoururl.com";

 

Or use jesirose' solution.

 

So you actually know a little about what is going on here, concatenation involves printing one or more strings when they have other things inbetween them. The concatenation operator is the " . " dot simple you see above, which basically means "and".

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.