Pee-H-Pee
08-30-2004, 07:22 PM
I am trying to generate a text field with the html code that people can use to copy and paste to show the exact same thing my php script generated. The user fills out a form to get the data for itemsperrow, LIMIT, description, category, length, etc...Here is the PHP script that generates the code. I am trying to get an example to show at the top of the page (which is already done by this script) and then a text area box under the example to show the html code for copying and pasting. Hope that made sense :D
<?
include("config.php");
echo "<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 width=100% bgcolor=#FFFFFF>\n";
$itemsperrow = 3;
$i = 1;
echo "<tr>";
$result = mysql_query("select * from TABLE WHERE CatName='$category' ORDER by name ASC LIMIT 9") or die (mysql_error());
while ($row = mysql_fetch_array($result)) {
$row[description]=substr($row[description], 0, 75);
if (is_int($i / $itemsperrow)) {
echo "<td align=center><b>$row[name]</b><br><img src=\"$row[image]\" border=\"0\" alt=\"$row[name]\"><br><div align=left>$row[description]</div><a href=\"http://www.site.com/product.asp?pid=$row[skew]\">Click Here >></A>";
echo "</td></tr><tr>";
}
else {
echo "<td align=center><b>$row[name]</b><br><img src=\"$row[image]\" border=\"0\" alt=\"$row[name]\"><br><div align=left>$row[description]</div><a href=\"http://www.site.com/product.asp?pid=$row[skew]\">Click Here >></A>";
echo "</td>";
}
$i++;
}
echo "</tr></table><br>";
?>
<?
include("config.php");
echo "<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 width=100% bgcolor=#FFFFFF>\n";
$itemsperrow = 3;
$i = 1;
echo "<tr>";
$result = mysql_query("select * from TABLE WHERE CatName='$category' ORDER by name ASC LIMIT 9") or die (mysql_error());
while ($row = mysql_fetch_array($result)) {
$row[description]=substr($row[description], 0, 75);
if (is_int($i / $itemsperrow)) {
echo "<td align=center><b>$row[name]</b><br><img src=\"$row[image]\" border=\"0\" alt=\"$row[name]\"><br><div align=left>$row[description]</div><a href=\"http://www.site.com/product.asp?pid=$row[skew]\">Click Here >></A>";
echo "</td></tr><tr>";
}
else {
echo "<td align=center><b>$row[name]</b><br><img src=\"$row[image]\" border=\"0\" alt=\"$row[name]\"><br><div align=left>$row[description]</div><a href=\"http://www.site.com/product.asp?pid=$row[skew]\">Click Here >></A>";
echo "</td>";
}
$i++;
}
echo "</tr></table><br>";
?>