ok... i have been working on this for a LONG time... so... maybe someone can help me...:
i have a kind of ubb code function on my page, which allows users to use simple tags like in this forum...
ok... now there is one tag which i CANT get to work...
it is this one:
[member]user name[/member]
this should print the following html code (for a user with the user id 238):
"<a href="members.php?userId=238">user name</a>"
the id should be retrieved from a mysql database (SELECT id FROM table WHERE username="user name - or something like that)
since i couldnt work out a way to isolate the username to use it for this query i wanted to settle for this:
"<a href="members.php?member=user%20name">user name</a>"
here i urlencode() the data to make sure it gets passed on correctly... but soon i noticed that this causes the exact same problem as above... i use preg_replace() to make sure both member tags are entered...
the line looks like this:
$string = preg_replace("/\[member\](.*?)\[\/member\]/si", "<a href=\"members.php?member=\\1\">\\1</a>", $string);
obviously the problem is, that i cant find a way to isolate the value \1 to use it for another transformation.
something like this:
$string = preg_replace("/\[member\](.*?)\[\/member\]/si", "<a href=\"members.php?member=" . urlencode(\\1) . "\">\\1</a>", $string);
which of course doesnt work though - or like in the preferred first version, retrieve the corresponding id from the database and enter it in the preg_replace() statement...
id be happy about any hint...
rock on - sid