Location: PHPKode > projects > ProPHP > ProPHP/content/ad_options/view.php
<?php
/*****************************************************************
************* BKWORKS PRO PHP V 0.5 BETA 1 ***********************
******************** BRYAN KOOIENGA ******************************
****************** DECEMBER 20, 2007 *****************************
*****************************************************************/

if(!defined("INDEX")) {  # Check to see if the template is calling for the script. If not, then
	header("location: ../../?view=home"); # Head to the homepage
}

############################################################
#                    GETS SITE NUMBER                      #
############################################################
$query = "SELECT site_number FROM sites WHERE site_url = '$username'";
$results = mysql_query($query) or die("Can't query because " . mysql_error());
$results = mysql_fetch_array($results);
$site_num = $results['site_number'];

###########################################################
#              GETS ALL ADS BASED ON USER ID              #
###########################################################
$query = "SELECT * FROM ads WHERE site_number = '$site_num'";
$results = mysql_query($query) or die("Can't query because " . mysql_error());
?>
<script language="javascript" type="text/javascript">
	function verify_delete_ad(ad_num) {
		var x = confirm("You have chosen to delete ad " + ad_num + ".\nDo you want to continue?");
		// Acts as a verification that you are really deleting what's posted.
		if(x) { // If yes, then head to the delete page
			location.href = "?view=delete&ad=" + ad_num;
		}
	}
</script>
<h3>View Current Advertisements</h3>
<table width="100%">
	<tr>
		<td align="center">Ad Number</td>
        <td align="center">Clicks</td>
		<td align="center">Ad URL</td>
		<td align="center">Size</td>
		<td align="center">View</td>
		<td align="center">Delete</td>
	</tr>
	<?php
	while($working_array = mysql_fetch_array($results)) {
		$intX2 +=1;
		echo "<tr>
			<td align=\"center\">$intX2</td>
			<td align=\"center\">$working_array[clicks]</td>
			<td align=\"center\"><a href=\"$working_array[ad_goto]\" target=\"_blank\">$working_array[ad_goto]</a></td>
			<td align=\"center\">$working_array[width]X$working_array[height]</td>
			<td align=\"center\"><a href=\"ads/$site_num/$working_array[image]\" target=\"_blank\">View</a></td>
			<td align=\"center\"><a onclick=\"verify_delete_ad($intX2)\">X</a></td>
		</tr>";
	}
	?>
		<tr>
			<td colspan="6" align="center">
            <?php if(! $intX2) { echo "<em><strong>You have no Advertisements.</strong></em><br />"; } ?>
            	<a href="?view=add_ad">Add an Advertisement!</a>
            </td>
		</tr>
	</table>
Return current item: ProPHP