/    Sign up×
Community /Pin to ProfileBookmark

Putting PHP code in a Variable?

Hi I have a form to mail script that I need to edit.

[CODE]
$List= ‘
<html>
<head>
<title>Orders</title>
</head>
<table border=1>
<tr>
<td>
<strong><u><font face=”comic sans ms” color=”#ff3705″><center>Product Code</center></font></strong></u>
</td>
<td>
<strong><u><font face=”comic sans ms” color=”#ff3705″><center>Product</center></font></strong></u>
</td>
<td>
<strong><u><font face=”comic sans ms” color=”#ff3705″><center>Quantity</center></font></strong></u>
</td>
</tr>
$kode
</table>
</html>
‘;
###############################################################################################
$headers = ‘MIME-Version: 1.0’ . “rn”;
$headers .= ‘Content-type: text/html; charset=iso-8859-1’ . “rn”;
$headers .= ‘From: [email protected]’ . “rn”;

$recipient=$EMail;
$subject=”RE: ORDER”;
$name=”3D-Xact”;
$email=”[email protected]”;
$message=$List;
$sucses = mail($recipient, $subject, $message, $headers);
[/CODE]

I have some PHP script that needs to be run in that email to complete the table of products.

Here is the PHP Code:

[CODE]
<?php
$New=”SELECT * FROM products”;
$result = mysql_query($New);
$num=mysql_num_rows($result);
$x = 0;
while($x < $num){
$Code = mysql_result($result,$x,’code’);
$Prod = mysql_result($result,$x,’prod’);
if (isset($_SESSION[$Code])){
?>
<tr>
<td>
<center><strong><font face=”comic sans ms” color=”#3300ff” size=”2″>
<?php
echo $Code ;
?>
</font></strong></center>
</td>
<td>
<center><strong><font face=”comic sans ms”
color=”#3300ff” size=”2″>
<?php
echo $Prod ;
?>
</font></strong></center>
</td>
<td>
<center>
<?php
echo $_SESSION[$Code]
?>
</center>
</td>
</tr>
<?php
}
$x++;
}
?>
[/CODE]

Is this possible and if so how?

Please help me. ?

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@stephan_gerlachJun 06.2007 — Try this. I took your code and cut it together. hope it helps.

[CODE]

$New="SELECT * FROM products";
$result = mysql_query($New);
$num=mysql_num_rows($result);
$x = 0;

$html_content = '';

while($x < $num){
$Code = mysql_result($result,$x,'code');
$Prod = mysql_result($result,$x,'prod');
if (isset($_SESSION[$Code])){

$html_content .= '<tr>
<td>
<center><strong><font face="comic sans ms" color="#3300ff" size="2">
'.$Code.'
</font></strong></center>
</td>
<td>
<center><strong><font face="comic sans ms"
color="#3300ff" size="2">
'.$Prod.'
</font></strong></center>
</td>
<td>
<center>
'.$_SESSION[$Code].'
</center>
</td>
</tr>
';
}
$x++;
}



$List= '
<html>
<head>
<title>Orders</title>
</head>
<table border=1>
'.$html_content.'
</table>
</html>
';
###############################################################################################
$headers = 'MIME-Version: 1.0' . "rn";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "rn";
$headers .= 'From: [email protected]' . "rn";

$recipient=$EMail;
$subject="RE: ORDER";
$name="3D-Xact";
$email="[email protected]";
$message=$List;
$sucses = mail($recipient, $subject, $message, $headers);

[/CODE]
×

Success!

Help @gogelpot spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.6,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...