Hello,
I built my first php program from reading tutorials (pretty exciting). To explain what I am trying to do, I have a classifieds section and a News section running from Phpbb on my site. I wanted to randomly display one featured ad from my classifieds on top of the News section.
What I've done: I wrote a Php script that ques the Classifieds data base using the Php Random feature with limit 1 attached to the SQL Querry. I tried including the file in PhpBB's overallfooter.php file for testing using an Include tag:
Code:<? include ("../../../my_script.php"); ?>
No results. I learned that the Php is not being parsed. I am hoping to learn how I can have it so my code is parsed into the header.
I was considering using Javascript, but from what I am reading in here, I am thinking that I need to somehow add the code as a function to one of the existing Phpbb files.
Here is the Code a Created
Code:$sql = "SELECT `id` , `attention_getter_url` , `image` , `title` , `description` , `price` , `location_city` , `location_state` FROM `classifieds`
WHERE featured_ad = 1 AND live = 1 ORDER BY RAND() LIMIT 1";
$result=mysql_query($sql,$db);
$row = mysql_fetch_array($result);
$id = $row["id"];
$image=$row["image"];
$title = urldecode($row["title"]);
$desc = urldecode($row["description"]);
$city = urldecode($row["location_city"]);
$state = urldecode($row["location_state"]);
$price = $row["price"];
$atn = $row["attention_getter_url"];
?>
<table cellpadding="1" cellspacing="1" border="0">
<tr>
<?php
$sql = "SELECT `thumb_url` FROM `classifieds_images_urls` WHERE classified_id = $id";
$result=mysql_query($sql,$db);
$row = mysql_fetch_array($result);
$thumb = $row["thumb_url"];
?>
<?
if ($thumb=="")
echo "<th colspan=\"2\" align=\"left\"><font size=\"1\" face=\"arial, helvetica, sans-serif\">Featured Classified Ad</font></th><tr>";
else
echo "<th colspan=\"3\" align=\"left\"><font size=\"1\" face=\"arial, helvetica, sans-serif\">Featured Classified Ad</font></th><tr><td width=\"98\"
align=\"center\" valign=\"top\" bgcolor=\"#efefef\"><a href=\"../../../index.php?a=2&b=$id\" title=\"$title\"><img
src=\"../../$thumb\" border=\"0\" alt=\"$title\"></a>";
?></td><td valign="top" bgcolor="#efefef" width="200"><a href="../../../index.php?a=2&b=<? echo $id; ?>"><b><? echo $title;
?></b>
<?
if ($atn=="")
echo "";
else
echo "<br><img src=\"../../../$atn\" border=\"0\">";
?><br><? echo $city; ?>, <? echo $state; ?><br>
<? if ($price=="0.00")
echo "";
else
echo "$$price"
?></a></td><td width="300" bgcolor="#efefef" valign="top">
<?
$rest = substr("$desc", 0, 100);
?><a href="../../../index.php?a=2&b=<? echo $id; ?>"><? echo $rest; ?>...</a></td>
</tr>
</table>