Jump to content

Need a Tip


Recommended Posts

for the mail send function in my mailbox i want to use the string replace function and for the 2 arrays to select from a database and I'm stuck as for how to do it.

This is what i have now.


	$a=mysql_query("SELECT `from` FROM `replace`");	
	$b=mysql_query("SELECT `to` FROM `replace`");
	$newmail = str_replace($from, $to, $msg);

Link to comment
Share on other sites

Re: Need a Tip

Using one query is much simplier, try it this way...

$sql_txt = 'SELECT `from`, `to` FROM `replace` WHERE `id` = \'' . $id . '\'';
$sql = mysql_query($sql_txt);
while($results = mysql_fetch_assoc($sql)) {
       $message = str_replace($results['from'], $results['to'], $message);
       // .. do whatever ..


But is your end goal to change a text from only one message, or how do you want this script to work?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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...