I want to use 1 dynamic php page to access a mysql database which i have achieved (don't ask me how) the header of the page has some links I.E. 1952,1953 etc. the sql query is set to retreive all records from the database that have 1952 in the year field what I want to do is when I click on a link instaed of loading another page I want it to change the sql query say from
Code: Select all
<?php $query = "SELECT * FROM numberones WHERE `year` = '1952'";?>Code: Select all
<?php $query = "SELECT * FROM numberones WHERE `year` = '1953'";?>This is the header music_header.tpl
Code: Select all
style type="text/css"&gt;
&lt;!--
@import url("../phpbb2/templates/fisubsilversh/fisubsilversh.css");
--&gt;
&lt;/style&gt;
&lt;table width="100%" height="100%" border="0" cellpadding="2" cellspacing="6"&gt;
&lt;tr&gt;
&lt;td align="center" valign="top"&gt;&lt;TABLE class=bodyline cellSpacing=0 cellPadding=0 width="100%" border=0&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;TABLE class=topbkg cellSpacing=0 cellPadding=0 width="100%" border=0&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;&lt;A href="http://127.0.0.1/phpBB2/index.php"&gt;&lt;IMG
title="Infinity's Total Music Forum Index" height=110
alt="Infinity's Total Music Forum Index"
src="phpBB2/templates/fisubsilversh/images/phpbb2_logo.jpg" width=240
border=0&gt;&lt;/A&gt;&lt;/TD&gt;
&lt;TD align=right width="100%"&gt;&lt;A
href="http://127.0.0.1/phpBB2/redirect.php?banner_id=1"
target=_blank&gt;&lt;IMG
src="phpBB2/images/banner/phpbb2_banner.gif"
alt="www.phpbb2.de - No.1" width="468" height="60"
border=0 title="www.phpbb2.de - No.1"&gt;&lt;/A&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;IMG height=4 alt=""
src="Infinity's Total Music Home_files/spacer.gif"
width=28&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;TABLE cellSpacing=0 cellPadding=2 width="100%" border=0&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class=topnav align=middle&gt;&amp;nbsp;&lt;A
href="http://127.0.0.1/phpBB2/portal.php"&gt;Home&lt;/A&gt;&amp;nbsp; • &amp;nbsp; &lt;A
href="http://127.0.0.1/phpBB2/search.php"&gt;1952&lt;/A&gt; &amp;nbsp;• &amp;nbsp;&lt;A
href="http://127.0.0.1/phpBB2/memberlist.php"&gt;1953&lt;/A&gt;&amp;nbsp; • &amp;nbsp;&lt;A
href="http://127.0.0.1/phpBB2/statistics.php"&gt;1954&lt;/A&gt;&amp;nbsp; • &amp;nbsp;&lt;A href="http://127.0.0.1/phpBB2/album.php"&gt;1955&lt;/A&gt;&amp;nbsp; • &amp;nbsp;&lt;A href="http://127.0.0.1/phpBB2/links.php"&gt;1956&lt;/A&gt;&amp;nbsp; • &amp;nbsp;&lt;A
href="http://127.0.0.1/phpBB2/calendar.php"&gt;1957&lt;/A&gt;&amp;nbsp; • &amp;nbsp;&lt;A href="http://127.0.0.1/phpBB2/recent.php"&gt;1958&lt;/A&gt; &amp;nbsp; • &amp;nbsp;&lt;A
href="http://127.0.0.1/phpBB2/nickpage.php?admin=Infinity"&gt;1959&lt;/A&gt; &lt;BR&gt;
&amp;nbsp;&lt;A href="http://127.0.0.1/phpBB2/staff.php"&gt;Staff Site&lt;/A&gt;&amp;nbsp; • &amp;nbsp;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;TABLE class=tbl cellSpacing=0 cellPadding=0 border=0&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class=tbll&gt;&lt;IMG height=4 alt=""
src="Infinity's Total Music Home_files/spacer.gif" width=8&gt;&lt;/TD&gt;
&lt;TD class=tblbot&gt;&lt;IMG height=4 alt=""
src="Infinity's Total Music Home_files/spacer.gif" width=8&gt;&lt;/TD&gt;
&lt;TD class=tblr&gt;&lt;IMG height=4 alt=""
src="Infinity's Total Music Home_files/spacer.gif"
width=8&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;!-- The javascript presents here comes from MyCalendar 2.2.6 from MojavLinux --&gt;
&lt;SCRIPT language=Javascript type=text/javascript&gt;
&lt;!--
var agt = navigator.userAgent.toLowerCase();
var originalFirstChild;
function createTitle(which, string, x, y)
&#123;
// record the original first child (protection when deleting)
if (typeof(originalFirstChild) == 'undefined')
&#123;
originalFirstChild = document.body.firstChild;
&#125;
x = document.all ? (event.clientX + document.body.scrollLeft) : x;
y = document.all ? (event.clientY + document.body.scrollTop) : y;
element = document.createElement('div');
element.style.position = 'absolute';
element.style.zIndex = 1000;
element.style.visibility = 'hidden';
if (document.all)
&#123;
element.style.width = '200px';
excessWidth = 50;
excessHeight = 20;
&#125;
else
&#123;
excessWidth = 0;
excessHeight = 20;
&#125;
element.innerHTML = '&lt;div class="bodyline" style="padding: 2px; text-align: left;"&gt;&lt;span class="gen"&gt;' + string + '&lt;/span&gt;&lt;/div&gt;';
renderedElement = document.body.insertBefore(element, document.body.firstChild);
renderedWidth = renderedElement.offsetWidth;
renderedHeight = renderedElement.offsetHeight;
// fix overflowing off the right side of the screen
overFlowX = x + renderedWidth + excessWidth - document.body.offsetWidth;
x = overFlowX &gt; 0 ? x - overFlowX : x;
// fix overflowing off the bottom of the screen
overFlowY = y + renderedHeight + excessHeight - window.innerHeight - window.pageYOffset;
y = overFlowY &gt; 0 ? y - overFlowY : y;
renderedElement.style.top = (y + 15) + 'px';
renderedElement.style.left = x + 'px';
// windows versions of mozilla are like too fast here...we have to slow it down
if (agt.indexOf('gecko') != -1 &amp;&amp; agt.indexOf('win') != -1)
&#123;
setTimeout("renderedElement.style.visibility = 'visible'", 1);
&#125;
else
&#123;
renderedElement.style.visibility = 'visible';
&#125;
&#125;
function destroyTitle()
&#123;
// make sure we don't delete the actual page contents (javascript can get out of alignment)
if (document.body.firstChild != originalFirstChild)
&#123;
document.body.removeChild(document.body.firstChild);
&#125;
&#125;
//--&gt;
&lt;/SCRIPT&gt;
&lt;style type="text/css"&gt;
&lt;!--
body &#123;
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
&#125;
.style1 &#123;
color: #0066CC;
font-weight: bold;
&#125;
.style2 &#123;color: #DBF9F9&#125;
.style3 &#123;font-size: 24px&#125;
.style4 &#123;
color: #FF6633;
font-weight: bold;
&#125;
.style5 &#123;
font-size: 36px;
font-weight: bold;
color: #FF9933;
&#125;
.style7 &#123;
font-size: 12px;
font-family: Arial, Helvetica, sans-serif;
color: #3366CC;
&#125;
.style8 &#123;color: #FF6633&#125;
a:link &#123;
text-decoration: none;
&#125;
a:visited &#123;
text-decoration: none;
&#125;
a:hover &#123;
text-decoration: none;
&#125;
a:active &#123;
text-decoration: none;
&#125;
--&gt;
&lt;/style&gt;Code: Select all
<?php include("music_header.tpl") ?>
<?php
$location = "localhost";
$username = "username";
$password = "password";
$database = "MYMUSIC";
$conn = mysql_connect("$location","$username","$password");
$year="1952";
if (!$conn) die ("Could not connect MySQL");
mysql_select_db($database,$conn) or die ("Could not open database");
$query = "SELECT * FROM numberones WHERE `year` = '1952'";
$result = mysql_query($query);
$numrows = mysql_num_rows($result);
echo "<table width='100%' border='1' cellpadding='2' cellspacing='2' bordercolor='#006699' align='center'>";
echo "<tr>";
echo "<td width='100%' background='../phpbb2/templates/fisubsilversh/images/cellpic3.gif'><div align='center' class='style2 style3'><strong>
$year </strong></div></td>";
echo "</tr>";
echo "</table>";
echo "<table width='100%' border='1' cellpadding='2' cellspacing='2' bordercolor='#006699' align='center'>";
echo "<td width='13%' background='../phpbb2/templates/fisubsilversh/images/cellpic1.gif'><div align='center' class='style1'>Date</div></td>";
echo "<td width='33%' background='../phpbb2/templates/fisubsilversh/images/cellpic1.gif'><div align='center' class='style1'>Artist</div></td>";
echo "<td width='39%' background='../phpbb2/templates/fisubsilversh/images/cellpic1.gif'><div align='center' class='style1'>Title</div></td>";
echo "<td width='6%' background='../phpbb2/templates/fisubsilversh/images/cellpic1.gif'><div align='center' class='style1'>Wks</div></td>";
echo "<td width='9%' background='../phpbb2/templates/fisubsilversh/images/cellpic1.gif'><div align='center' class='style1'>d/l</div></td>";
while($row = mysql_fetch_array($result))
{
echo "<tr><td background='../phpbb2/templates/fisubsilversh/images/cellpic_nav.gif'><div align='center'>$row[year]</div></td></tc>";
echo "<tc><td background='../phpbb2/templates/fisubsilversh/images/cellpic_nav.gif'><div align='center'>$row[artist]</div></td></tc>";
echo "<tc><td background='../phpbb2/templates/fisubsilversh/images/cellpic_nav.gif'><div align='center'>$row[title]</div></td></tc>";
echo "<tc><td background='../phpbb2/templates/fisubsilversh/images/cellpic_nav.gif'><div align='center'>$row[weeksatone]</div></td></tc>";
echo "<tc><td background='../phpbb2/templates/fisubsilversh/images/cellpic_nav.gif'><div align='center'>$row[dllink]</div></td></tr>";
}
echo "</table>";
?>
<?php include("music_footer.tpl") ?>
?>