Jump to content

Is this possible?


joshbedo

Recommended Posts

Im messing around and attempting to build a small MVC im stuck a little on the model class what i want to do is

call an object with a function which connects to a database and converts the array to variables like this.

	
public function getArticle($text)
{
	$this->addConnection('localhost', 'imstill', hash('passwordhash'), 'imstill_school');
	$latest = mysql_query("select * from article order by id desc");

	while ($latest_articles = mysql_fetch_array($latest)){	

			if(is_array($latest_articles))

			{

				foreach($latest_articles as $key => $value)

					$$key = stripslashes($value);
			}

			// if statement above runs through the array of articles being fetched from the database

			// and then adds stripslashes and assigns key value

			// makes it so i dont have to add .$latest_articles[value]. everytime can just add .$value.
		//echo $postedby;
		echo $text;
	}
}

 

then at the bottom of function have the variable which is passed into the function which would be html and variables

<?php echo $registry->getObject("model")->getArticle('<div class="section"><h2>$name</h2><span class="meta">$date</span>');?>

 

it echos all of the html but it doesnt get the values of the variable is there anyway to do this? by the way im using the registry pattern to call model classes.

Link to comment
https://forums.phpfreaks.com/topic/229091-is-this-possible/
Share on other sites

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.