0

ok what i am trying to do is have the user insert cretin things like %address%, and what will happen is i would have data be recalled from the DB and replaced with what it needs to be
ex:
%address%
=
1234 main st


this is what i have idk if it is a step in the right direction or now.

$result = mysql_query("SELECT * FROM table WHERE id='1' ");
        while($myrow = mysql_fetch_assoc($result))
             { 

//includes the data of the user input
$content = $myrow['content'];
				 
	 $result = mysql_query("SELECT * FROM table WHERE idr='$id' ");
        while($myrow = mysql_fetch_assoc($result))
             { 
			 
$address = $myrow['address'];


				 
				 $searchArray = array("%address%", "%state%", "%city%");
				 $replaceArray = array($address, "state", "city");
				 $content = str_replace($searchArray, $replaceArray, $content);
				 
			 }
}
2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by cwarn23
0

Well the only comment I have is that you could do a better database design if I'm reading that code correctly. Also, what is your database design as in what columns are in what table(s)? Although I would design it with only one loop, as pointed out in your code, str_replace is the way to go.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.