Jump to content

I'm not sure this is possible? But if it is, how would I do it?


jamesxg1

Recommended Posts

Hiya peeps!

 

I'm not sure this is possible but here is a example code of what I'm trying to do, I hope it shows my intentions;

 

					if(preg_match_all("/\%([A-Z]*)%/", $file, $match)) {
						while($results = mysql_fetch_array($runSearch));

						foreach($match[1] as $MK => $MV) {
							$TR .= str_replace('%' . $MV . '%', $results[$MV], $match[1]);
						}

						return $TR;							
					} else {
						return $this->lang->displayContent('39');
					}

 

I would test it and make life a whole lot easier; but I have built the whole site freehand and I know 100% the rest of the code will work, this on the other hand has stumped me! I also have now sample data in the mysql database and I do not have the tables correctly setup yet. So I pretty much on a short string with this one!

 

Any help would be very much appreciated!

 

Many thanks,

 

James.

What I'm basically trying to do is this;

 

Input into the script;

<a href="blah.php?id=%id%">%name%</a>

 

and then have the %CONTENT% replaced with results from an array fetched from the mysql DB.

 

EG;

 

Input;

<a href="blah.php?id=%id%">%name%</a>

 

Output;

<a href="blah.php?id=1">John Doe 1</a>
<a href="blah.php?id=2">John Doe 2</a>
<a href="blah.php?id=3">John Doe 3</a>

 

And so on, is this possible? and am I on the right tracks? lol.

 

Many thanks,

 

James.

I've got this so far, but due to being unable to test it I'm not sure if it will work. Would someone with a good all seeing eye take a look and tell me if this will work please lol.

 

					if(strpos($replacements, '%') == true) {
						while($results= mysql_fetch_assoc($runSearch)) {
							if(preg_match("/\%([A-Z]*)\%/", $replacements, $containers)) {
								foreach($containers as $CK => $CV) {
									$TR .= str_replace('%' . $CV . '%', $results[$CV], $replacements);
								}
							}
						}
						return $TR;							
					} else {
						return $this->lang->displayContent('39');
					}

 

Many thanks,

 

James.

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.