Jump to content

Recommended Posts

How would I go about displaying the html code of a page on the page?

 

For example, let's say I wanted to take one of the selections on the dropdown menu at http://1minloans.com/roman2/index.php, and have a box somewhere on the page that shows the complete HTML of what is displayed in said dropdown.

 

From what I've read, I understand that you would do this through htmlentities, but since I'm a major noob to PHP (this is pretty much my first ever PHP project), I'm not quite grasping this concept. Any help would be much appreciated :)

Link to comment
https://forums.phpfreaks.com/topic/137400-displaying-html-through-php/
Share on other sites

Ah yes, the file is a .php extension. Basically, I'm trying to display the tables that show up when I use the following code (which is the actual sourcecode of http://1minloans.com/roman2/index.php

 

<?php
include('common/dbconnect.php');

$theID = $_POST['cID'];

if($theID != '') {
$sql = mysql_query("SELECT * FROM tblcars WHERE cID = $theID");
$row = mysql_fetch_array($sql);

$cbody = $row['cbody'];
$sql3 = mysql_query("SELECT btype FROM tblbody WHERE bID = $cbody");
$row3 = mysql_fetch_array($sql3);

$cdrive = $row['cdrive'];
$sql4 = mysql_query("SELECT dtype FROM tbldrive WHERE dID = $cdrive");
$row4 = mysql_fetch_array($sql4);
}

echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Language" content="en-us" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Car Website</title>
<link rel="stylesheet" href="common/style.css" type="text/css" />
</head>

<body>

<form name="choosecar" action="index.php" method="post">
<div>Choose Vehicle: <select class="txtselect" name="cID">';
	$sql2 = mysql_query("SELECT * FROM tblcars");
	$numrows2 = mysql_num_rows($sql2);

	if ($numrows2 == 0) {
  			echo '<option value="">No Vehicles</option>';
	} else {
		echo '<option value="">Choose Vehicle</option>';
		while($row2 = mysql_fetch_array($sql2)) {
			echo '<option ' . ($row['cID']==$row2['cID'] ? 'selected' : '') . ' value="'.$row2['cID'].'">'.$row2['ctitle'].'</option>'; 
		}
	}
echo '</select>
<input class="subbtn" type="submit" name="submit" value="Submit" /></div>
</form>';

if($theID != '') {
echo '<table style="width: 760; height: 759px" bgcolor="grey">
<tr>
	<td border="1">
<A HREF="http://eliteautoweb.com/apply2.html" TARGET="_blank"><IMG SRC="http://i428.photobucket.com/albums/qq2/onebigredfish/eliteautoweb.gif" BORDER="0"></A>
	<table style="width: 650px; height: 600px" BORDER="0" align="center">
		<tr>
			<td BGCOLOR="black" ALIGN="center" style="height: 13px; width: 288px"><FONT COLOR="white"><b>'.$row['ctitle'].'</b></FONT></td>
			<td BGCOLOR="black" ALIGN="center" style="height: 13px" class="style29"><FONT COLOR="white"><strong>'.$row['cslogan'].'</strong></FONT></td>
		</tr>

		<tr>
			<td style="width: 288px; height: 212px" BGCOLOR="black" BORDER="1" VALIGN="middle">';	
			if($row['cphoto'] == '') {
				echo '<img src="images/nophoto.gif" />';
			} elseif($row['cphoto'] != '') {
				echo '<img src="images/cars/'.$row['cphoto'].'" style="height: 210px;" />';
			}
			echo '</td><td style="height: 212px" VALIGN="top" BGCOLOR="black">

			<table style="width: 100%; height: 254px">
				<tr>
					<td style="height: 8px" BGCOLOR="black" ALIGN="center"><FONT COLOR="white"><strong>Location: '.$row['clocation'].'</strong></FONT></td>
				</tr>

				<tr>
					<td valign="top" align="center" BGCOLOR="grey" style="height: 240px"><big><FONT COLOR="white">Features:</FONT></big>
					<table style="width: 100%; height: 173px" class="style20" BGCOLOR="black">
						<tr>
							<td style="width: 120px"><FONT COLOR="white"><b>Make:</b></td>
							<td><FONT COLOR="white"><b>'.$row['cmake'].'</b></FONT></td>
						</tr>

						<tr>
							<td style="width: 120px"><FONT COLOR="white"><b>Year:</b></td>
							<td><FONT COLOR="white"><b>'.$row['cyear'].'</b></FONT></td>
						</tr>

						<tr>
							<td style="width: 120px"><FONT COLOR="white"><b>Model:</td>
							<td><FONT COLOR="white"><b>'.$row['cmodel'].'</b></td>
						</tr>

						<tr>
							<td style="width: 120px"><FONT COLOR="white"><b>Body Style:</td>
							<td><FONT COLOR="white"><b>'.$row3['btype'].'</b></td>
						</tr>

						<tr class="style4">
							<td style="width: 120px"><FONT COLOR="white"><b>Exterior Color:</td>
							<td><FONT COLOR="white"><b>'.$row['cextcol'].'</b></td>
						</tr>

						<tr class="style4">
							<td style="width: 120px"><FONT COLOR="white"><b>Interior Color:</td>
							<td><FONT COLOR="white"><b>'.$row['cintcol'].'</b></td>
						</tr>

						<tr class="style4">
							<td style="width: 120px; height: 22px;"><FONT COLOR="white"><b>Condition:</td>
							<td style="height: 22px"><FONT COLOR="white"><b>'.$row['ccondition'].'</b></td>
						</tr>

						<tr>
							<td style="width: 120px; height: 7px;"><FONT COLOR="white"><b>Drive Type:</td>
							<td style="height: 7px"><FONT COLOR="white"><b>'.$row4['dtype'].'</b></td>
						</tr>
					</table>
					</td>
				</tr>
			</table>
			</td>
		</tr>

		<tr>
			<td width="288" height="223" valign="top" BGCOLOR="black">
			<table WIDTH="105%" height="320" BGCOLOR="black" BORDER="0">
				<tr>
					<td style="height: 1px; width: 147px" ALIGN="center"><FONT COLOR="white"><big>Asking Price: </big><b><big>'.$row['cprice'].'</big></b></FONT></td>
				</tr>

				<tr>
					<td valign="top">
					<table width="100%" height="100%" BGCOLOR="white">

						<tr>
							<td style="height: 18px"><FONT COLOR="black"><B><U>Contact Information:</U></B></FONT></td>
						</tr>

						<tr>
							<td valign="top" HEIGHT="100%"><B>'.$row['caddress'].'</B><br /><FONT COLOR="black"><B>Phone: '.$row['cphone'].'</B></FONT><br /><br /><a href="http://eliteautoweb.com/apply2.html" target="_blank"><img src="http://i428.photobucket.com/albums/qq2/onebigredfish/elitesmall.gif" BORDER="0"></a>
						</td>
						</tr>
					</table>
					<br /><br /><br />
					</td>
				</tr>
			</table>
			</td>

			<td height="223" VALIGN="top">
			<table width="100%" height="320" BGCOLOR="black" VALIGN="top" BORDER="0">
				<tr>
					<td HEIGHT="1" align="center" VALIGN="top"><FONT COLOR="white"><b>Attributes</b></FONT></td>
				</tr>

				<tr VALIGN="top">
					<td valign="top" VALIGN="top" style="height: 292px" BGCOLOR="white"><b>Exterior:</b>
					<table style="width: 100%" VALIGN="top">
						<tr>
							<td bgcolor="#C0C0C0"><small>'.$row['cext'].'</small></td>
						</tr>
					</table>
					<br />
					<b>Electronics:</b>
					<table style="width: 100%">
						<tr>
							<td bgcolor="#C0C0C0"><small>'.$row['celec'].'</small></td>
						</tr>
					</table>
					<br /><b>Accessories:</span></b>
					<table style="width: 100%">
						<tr>
							<td bgcolor="#C0C0C0"><small>'.$row['caccess'].'</small></td>
						</tr>
					</table>
					</td>
				</tr>
			</table>
			</td>
		</tr>
	</table>
	</td>
</tr>
</table>';

}

echo '</body>
</html>';
?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

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

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

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

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.