Jump to content

PHP Website

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
6 replies to this topic

#1
domestic

domestic

    Learning Programmer

  • Members
  • PipPipPip
  • 44 posts
Hey guys. A while ago I asked about the frames/php require thing. After this, I went looked around and started on building the website, located here

So far the code looks something like this:

index.php
<?php


$site_title = "Aberdeen Student Radio";

$page_title = "Demo Page v1";


$main .= '<img src="../../Media/Pix/mm_entertainment_image.jpg" width="100" height="100">';

$main .= "<div>


//formating attempt - see below

Welcome to the ASR demo page


<br>

<br>


Listen in live to FREE internet radio, coming to you from Aberdeen University Campus, Student Radio for you by you!


<br>

<br>


Aberdeen Student Radio is finally here after 12 years of silence, radio is back in Aberdeen!

Dreams of Student Radio are coming true for over 40 DJs who will be filling your ears from now on. Also not forgetting the News, Sports and Student issues teams who will be bringing you what you won't hear anywhere else!


<br>

<br>


ON-AIR 10am till 9pm, Monday to Friday

ON-AIR 10am till 5pm, Saturday

Click on one of the logos at the top of the page to listen during ON-AIR hours.

If you have problems listening then please email us with all the details.


<br>

<br>


To Get Involved...

To get involved (you don't need any experience just enthusiasm), please go to the 'Get Involved' page.


</div>";


require('header.php');

require('footer.php');

require('news.php');

require('gigs.php');

require('layoutlow.php');


?>

layoutlow.php
<html>

<head>

<title>

<?php echo "$site_title - $page_title"; ?>

</title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

</head>



<body bgcolor="#FFFFFF" text="#000000" link="#0000ff" vlink="#800080">


<!--Overall Size Is Set Here = 1400px-->

<table width="1400px" height="100%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#ffffff">

  <tr>

    <td colspan="3" align="bottom" valign="bottom" height="100">

    <p><font size="20pt" face="Base 02">

      <img src="../Pictures/LeftBarH.jpg" width="180" height="100"><img src="../Pictures/TBarH.jpg" width="1040" height="100"><img src="../Pictures/LeftBarH.jpg" width="180" height="100">

    </font></p>

    </td>

  </tr>

  <tr>

  

<!--The individual column sizes are set here, Left to Right, 300,800,300-->

    <td width="300px" colspan="1" align="center" valign="top" bgcolor="#f0f0f0">

      <div align="left"><font face="Calibri"><?php echo $news; ?></font></div>

    </td>

    

    <td width="800px" align="center" valign="top">

      <div align="left"><font face="Calibri"><?php echo $main."\n"; ?></font></div>

    </td>

    

    <td width="300px" colspan="1" align="center" valign="top" bgcolor="#f0f0f0">

      <div align="center"><font face="Calibri"> <?php echo date("F j, Y"); ?></font></div>

      <div align="center"><font face="Calibri"> <?php echo date("g:i a"); ?></font></div>

      <div align="right"><font face="Calibri"> <?php echo $gigs; ?></font></div>

    </td>

  </tr>

  <!--End of set sizes-->

  

  <tr>

    <td align="center" valign="top" height="5" bgcolor="#f0f0f0">

      <div align="center"><font size="2" face="Calibri"><a href="resolutions.php">High Res Version</a></font></div>

    <a href="http://www.ausa.org.uk/"><img src="../Pictures/AUSA.gif" alt="ASR" width="50" height="52" align="absmiddle"></a></td>

    <td align="center" valign="baseline" height="5"><div align="center"><font face="Calibri"><a href="http://www.abdn.ac.uk/~u41am6"><?php echo $footer; ?></a></font></div></td>

  </tr>

</table>

</body>


</html>


Well, you are probably going to point plenty of flaws in my code, so feel free to point out all my errors.

Additionally, I was wondering if you could help me out with this question. It probably is answered in a million places online, but not being sure what to google to find it, I'm asking you guys.

In the index.php you will notice I use $main= to type in the text I want displayed. However, I cannot get it to format the code from within index.php. I would use echo but it won't work when already with the $main section. I am also aware I could split it into seperate $main sections however, I'd rather not if possible.

Inserting the code in the index.php page (see above for exact placement):
<font size="20pt">

Welcome to the ASR demo page

</font>

results in:
Parse error: parse error, unexpected T_LNUMBER in /home/bio-u1/u41am6/PCFILES/public.htm/ASR/PHP/index.php on line 9

The error is displayed within the browser.

So, if you can help with the formating, or have noticed some other stupid rookie thing I've done (probably the whole thing) then please let me know.

Cheers
Domestic
.
Posted Image

Programming Languages: Java, VB6, VB2005 (.NET2)
Web Languages: HTML, CSS, JS

Website: http://abdn.ac.uk/~u41am6

Opportunity is missed by most people because it is dressed in overalls and looks like work.

#2
domestic

domestic

    Learning Programmer

  • Members
  • PipPipPip
  • 44 posts
ok, 1sty sorry for double post but i felt it neccessary.

2ndly, i have done more reading up and stumbled on how i was ment to use php. And it is pretty different from my failed attempt!

Anyways, I'm off to retry but with my new found knowledge.....
.
Posted Image

Programming Languages: Java, VB6, VB2005 (.NET2)
Web Languages: HTML, CSS, JS

Website: http://abdn.ac.uk/~u41am6

Opportunity is missed by most people because it is dressed in overalls and looks like work.

#3
John

John

    Writes binary right handed and hex left handed

  • Moderators
  • 6,321 posts
It has to do with your usage of single ( ' ) and double ( " ) quotes. Without getting into a long explination there are four ways you use quotes:

1. Single-Double
2. Double-Single
3. Single-Escaped Single
4. Double-Escaped Double

I always use choice two. What does this mean? Well as you clearly demonstrate, when you echo something, you can encapsulate the data with a single quote

echo 'CodeCall';
or
echo "CodeCall";
However, if you are to use quotes inside the main quotes, you would have to alternate the type, or escape. Below are acceptable uses:

1.
echo '<a href="http://www.codecall.net">CodeCall</a>';
2.
echo "<a href='http://www.codecall.net'>CodeCall</a>";
3.
echo '<a href=\'http://www.codecall.net\'>CodeCall</a>';
4.
echo "<a href=\"http://www.codecall.net\">CodeCall</a>";

So if that wasn't clear, you cant use double quotes inside double quotes without escaping them, or replacing them with single quotes.

$main .= "<div>

<font size='20pt'>
Welcome to the ASR demo page
</font>  
or
$main .= "<div>

<font size=\"20pt\">
Welcome to the ASR demo page
</font> 


#4
domestic

domestic

    Learning Programmer

  • Members
  • PipPipPip
  • 44 posts
Well, lets say, the website has changed a little bit since last time!

I decided I didnt really like the way it works. Plus it didnt really work well. Anyways, I got a new version located here: ASR demo v2

Ok, well apart from some images not being right and such, I have a few probs:irritated:.

1 - When changing page, the pages moves :confused:
2 - The contact page likes to replicate itself at the bottom of the page


The website works like this:

The index page is loaded index.php
if there is nothing at end then it loads home.html
other pages are loaded via an address extension: index.php?location=PAGE

INDEX.PHP
<noscript>

<meta http-equiv="refresh" content="2; URL=enable_javascript.php">

</noscript>


<?php


/* Aberdeen Student Radio demo page version 2

   Designed and maintained by Andrew MacKillop

   Copyright Andrew MacKillop 2007

 */


//get current location. if null then goto home page

$location=$_GET['location']; if (empty($location)) {

  $location='home';

}


changelocation($location);


function changelocation($location) {


//include the starting tags

include ('header.html');




//Top

echo '  <table width="1000px" height="100%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#ffffff">';

echo '  <tr>';

echo '    <td colspan="3" align="bottom" valign="bottom" height="100">';

echo '      <p><font size="20pt" face="Base 02">';

echo '        <img src="../Pictures/LeftBarH.jpg" width="180" height="100"><img src="../Pictures/TBarH.jpg" width="640" height="100"><img src="../Pictures/LeftBarH.jpg" width="180" height="100">';

echo '      </font></p>';

echo '    </td>';

echo '  </tr>';




//Top - navbar

echo '	<tr>';

echo '  <td></td>';

echo '	  <td align="center" valign="top">';

            include ("navbar.html");

echo '	  </td>';

echo '  </tr>';

echo '  <tr>';

  

  

//Left

echo '    <td width="200px" colspan="1" align="center" valign="top" bgcolor="#f0f0f0">';

echo '      <div align="left"><font face="Calibri">';

              include ("left.html");

echo '      </font></div>';

echo '    </td>';



//Main section

echo '    <td width="600px" align="center" valign="top">';

echo '      <div align="left"><font face="Calibri">';

              $newlocation = $location.".html";

              include ($newlocation);

echo '      </font></div>';

echo '    </td>';



//Right

echo '    <td width="200px" colspan="1" align="center" valign="top" bgcolor="#f0f0f0">';

echo '      <div align="center"><font face="Calibri">';

echo 	      date("F j, Y");

echo '	    </font></div>';

echo '      <div align="center"><font face="Calibri">';

echo 		  date("g:i a");

echo '      </font></div>';

echo '      <div align="right"><font face="Calibri">';

	 		  include('gigs.html');

echo '	    </font></div>';

echo '    </td>';

echo '  </tr>';



//Bottom left

echo '  <tr>';

echo '    <td align="center" valign="top" height="5" bgcolor="#f0f0f0">';

echo '      <a href="http://www.ausa.org.uk/"><img src="../Pictures/AUSA.gif" alt="ASR" width="50" height="52" align="absmiddle"></a>';

echo '    </td>';



//Bottom middle

echo '    <td align="center" valign="baseline" height="52">';

echo '      <div align="center"><font face="Calibri"><a href="http://www.abdn.ac.uk/~u41am6">Designed by Andrew MacKillop</a></font></div>';

echo '    </td>';



//Bottom right

echo '  <tr>';

echo '    <td align="center" valign="top" height="5" bgcolor="#f0f0f0">';

echo '    </td>';

echo '  </tr>';



//End of table

echo '</table>';


switch ($location) {

  case 'index': 	include ('home.html');

    break;

  case 'contact': 	include ('contact.html');

    break;

}


echo '</td></tr></table>';


include ('footer.html');


}


?>


HOME.HTML
<html>

<style type="text/css">

<!--

.style1 {font-family: Calibri}

.style2 {

	

	font-family: Calibri

	font-size: 24px;

	font-weight: bold;

	font-family: Calibri;

	font-size: 24px;

	font-style: normal;

	font-variant: normal;

	color: #000000;

	text-decoration: underline;

	text-align: center;

}

-->

</style>

<div align="center" class="style2">Welcome to the ASR demo page</div>

<br />

<br />


<div align="left" class="style1">

  <p align="center">Its time to turn on and tune into the Number 1 radio station for students in Aberdeen!</p>

  <p align="center">After a short 12 year break, the ASR is back, and better then ever! Using super techie stuff, the ASR is now being broadcast straight to your computer in crystal clear format, bringing pleasure to your eardrums!</p>

  <p align="center">So <a href="index.php?location=listen.html">tune in</a> and let our many DJs entertain you</p>

</div>

</html>



CONTACT.HTML
<html>

<style type="text/css">

<!--

.style1 {font-family: Calibri}

.style2 {

	font-size: 18px;

	font-weight: bold;

	text-decoration: underline;

}

.style3 {

	font-size: 24px;

	font-weight: bold;

	text-decoration: underline;

}

-->

</style>

<div align="left" class="style1">


<div align="center" class="style3">Contact The ASR</div>

  

  <p><span class="style2">Contact the Studio</span><br />

    <b>Text the studio:</b> Text "ASR" then your name and message to 83831. Texts cost 50p (23p funds the station)<br />

    <b>Phone the studio:</b> 01224 274343<br />

    <b>Email the studio:</b> <a href="mailto:dj.radio@abdn.ac.uk">dj.radio@abdn.ac.uk</a><br />

      <br />

      <span class="style2">Post </span><br />

  Aberdeen Student Radio,<br />

  The Hub,<br />

  Elphinstone Road,<br />

  Aberdeen<br />

  AB24 3TU<br />

  Scotland<br />

  <br />

  

  <span class="style2">The Committee</u>  </span><br />

  </p>

  <table class="style1" width="450" border="0">

    <tr height="40">

      <td class="style1">

        <div align="center">Station Manager</div>

      </td>

      <td class="style1">

        <div align="center">Head DJ</div>

      </td>

      <td class="style1">

        <div align="center">Technical Manager</div>

      </td>

    </tr>

    

    <tr>

      <td class="style1"><div align="center">Sandy McKinnon<br />

        <a href="mailto:manager.radio@abdn.ac.uk">manager.radio@abdn.ac.uk</a></div>

      </td>

      <td class="style1"><div align="center">Cearúil Swords<br />

        <a href="mailto:headdj.radio@abdn.ac.uk">headdj.radio@abdn.ac.uk</a></div>

      </td>

      <td class="style1"><div align="center">Harry Payne<br />

        <a href="mailto:tech.radio@abdn.ac.uk">tech.radio@abdn.ac.uk</a></div>

      </td>

    </tr>

    

    <tr height="50">

      <td><div align="center"></div></td>

      <td><div align="center"></div></td>

      <td><div align="center"></div></td>

    </tr>

    

    <tr height="40">

      <td class="style1">

        <div align="center">Head Reporter</div>

      </td>

      <td class="style1">

        <div align="center">Sports Commentator</div>

      </td>

      <td class="style1">

        <div align="center">Student Issues Reporter</div>

      </td>

    </tr>

    

    <tr>

      <td class="style1"><div align="center">Davide Grody<br />

        <a href="mailto:news.radio@abdn.ac.uk">news.radio@abdn.ac.uk</a></div>

      </td>

      <td class="style1"><div align="center">David Millar<br />

        <a href="mailto:sports.radio@abdn.ac.uk">sports.radio@abdn.ac.uk</a></div>

      </td>

      <td class="style1"><div align="center">En Tan<br />

        <a href="mailto:issues.radio@abdn.ac.uk">issues.radio@abdn.ac.uk</a></div>

      </td>

    </tr>

    

  </table>

</div>

</html>


Cheers,
Domestic
.
Posted Image

Programming Languages: Java, VB6, VB2005 (.NET2)
Web Languages: HTML, CSS, JS

Website: http://abdn.ac.uk/~u41am6

Opportunity is missed by most people because it is dressed in overalls and looks like work.

#5
John

John

    Writes binary right handed and hex left handed

  • Moderators
  • 6,321 posts
1. The page shifts because there is a scroll bar present on the Contact page while there is not a scroll bar present on the home page.

2. Rather than using include() try require_once()

#6
domestic

domestic

    Learning Programmer

  • Members
  • PipPipPip
  • 44 posts
sweet. that solves the replicating problem. And the table doesnt shift orisontally now cheers.

However, it does still shirt vertically at the top. any ideas?
and how could i fix the problem of horizontal shifting if the page is going to be large enough that u vertically scroll?

Cheers mate. Ur awesome!
Domestic
.
Posted Image

Programming Languages: Java, VB6, VB2005 (.NET2)
Web Languages: HTML, CSS, JS

Website: http://abdn.ac.uk/~u41am6

Opportunity is missed by most people because it is dressed in overalls and looks like work.

#7
John

John

    Writes binary right handed and hex left handed

  • Moderators
  • 6,321 posts
The vertical shifting below the header, just seems to be a minor issue with your HTML and CSS not being in the same format for both pages.