några sidor på nätet om PHP programmering

Sök efter  
Börja här Uppgifter Testa dig själv Tips Sidokarta mm. Länkar Sök

links.php compat.php settings.php source.php main.txt Typisk sida

5.2.6 Typisk sida

En typisk websida i siten. Ser lite hemsk ut när man ser html-koden, men så här ser den ut i Dreamweaver:

Editeringen sker enkelt eftersom jag inte har "tyngt in" PHP kod överallt utan har klasser och funktioner som genererar behövlig html kod.

 

Och så här ser källkoden ut:

<?php session_start(); Header( "Last-Modified: " . gmdate ("D, d M Y H", getlastmod () ) );?>
<html><!-- #BeginTemplate "/Templates/phpkurs.dwt" -->
<head>
<?php
include_once("./inc/links.php");
$listFile = "./data/main.txt" ;
$navList = new linkList($listFile );
$count = $navList->GetListCount () ;
$title = "PHP kurs - " .$navList->TheText ( $navList->currInd );
include_once(
"./inc/source.php");
?>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<?php echo "<!-- " . count_it() . " -->\r\n"; ?>
<title><?php echo $title; ?></title>
<meta name="description" content="Kursmaterial om PHP programmering">
<meta name="keywords" content="PHP, programmering, webbkurs, österbotten">
<meta name="author" content="Anders Enges">
<script language="JavaScript">
<!--
function SeekPHP_net() {
    if ( document.ss.seek.value.length > 0)
      window.open('http://www.php.net/manual-lookup.php?function=' + document.ss.seek.value,'_new','toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=740,height=500');
}
function ttt()
{
    if ( document.ss.seek.value.length > 0)
    {
        switch( document.ss.where.options[document.ss.where.selectedIndex].value )
        {
            case "1":
                document.location.href = "seek.php?seek=" + document.ss.seek.value;
                break;
            case "2":
                   window.open('http://www.php.net/manual-lookup.php?function=' + document.ss.seek.value,'_new');
                break;
            case "3":
                window.open('http://pear.php.net/package-search.php?pkg_name=' + document.ss.seek.value + '&bool=AND&sumbit=Search','_new');
                break;
            case "4":
                alert ('hepp');
                break;

        }
        return true;
    }
    else
    return false;
}
//-->
</script>
<link rel="stylesheet" href="phpkurs.css" type="text/css">
</head>
<body bgcolor="#FEFEFE" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" link="#0000CC" vlink="#0000CC" alink="#0000CC">
<center>
  <table border="0" width="100%" height="8">
    <tr>
      <td width="240" height="46" valign="top" style="letter-spacing:8px;font-family:monospace; color: #333333; font-size:24px; font-weight:normal;" bgcolor="#FFFFFF">
        <a href="http://www.enges.org/"><img src="../images/enges2.gif" width="300" height="40" border="0" vspace="2" hspace="2" align="top"></a></td>
      <td width="100%" valign="middle" align="center">
        <h4>n&aring;gra sidor p&aring; n&auml;tet om PHP programmering</h4>
      </td>
    </tr>
    <tr>
      <td height="3"><img height="1" width="240" src="/phpkurs/spacer.gif"></td>
      <td></td>
    </tr>
  </table>
  <table width="641" border="0" cellpadding="0" cellspacing="0" align="center" bgcolor="#FFFFFF" height="329">
    <tr>
      <td valign="top" colspan="3" nowrap height="31">
        <table border="0" cellpadding="0" cellspacing="0" width="640">
          <tr>
            <td height="27" width="640"  valign="bottom" align="right" class="toppen">
              <form name="ss" onsubmit="return ttt();" action="seek.php" style="margin:0px; padding:0px;">
                Sök efter
                <input type="text" name="seek" value="<?php echo isset($_REQUEST["seek"]) ? $_REQUEST["seek"] : "" ?>" style="margin:0px; font-size:10px; height:17px; border: 1px solid #999999;" >
                p&aring;
                <select name="where" style="margin:0px; font-size:10px; height:17px; border: 0px solid #999999;">
                  <option value="1" selected>Dessa sidor</option>
                  <option value="2">www.php.net</option>
                  <option value="3">PEAR</option>
                </select>
                <input type="button" onclick="ttt()" name="Submit" value="S&ouml;k" class="lille">
                &nbsp;
              </form>
            </td>
          </tr>
          <tr>
            <td height="4"></td>
          </tr>
        </table>
      </td>
    </tr>
    <tr>
      <td valign="top" height="18" colspan="2">
        <?php $navList->Putlevel1(); ?>
      </td>
      <td width="65" valign="middle" align="right">
        <?php $navList->PutNextPrev(); ?>
      </td>
    </tr>
    <tr>
      <td width="115" height="406" valign="top" class="linklist">
        <?php $navList->Putlevel2(); ?>
      </td>
      <td valign="top" colspan="2" class="rightborder">
        <p style="margin-left:0px">
          <?php $navList->PutLevel3(); ?>
        </p>
        <h3>
          <?php echo $navList->TheTitleAutoNum( $navList->currInd ); ?>
        </h3>
        <!-- #BeginEditable "body" -->
        <p>Inte f&ouml;r att jag tror n&aring;n bryr sig, men h&auml;r finns alla
          programfiler som styr hela sajten. Det mesta cirklar kring en (alldeles
          f&ouml;r) stor klass, som sk&ouml;ter det mesta. </p>
        <p>Jag s&auml;tter mest ut dessa s&aring; jag kan kolla vad jag har gjort.
          Jag anv&auml;nder r&auml;tt ofta Internet som en luntlapp &aring;t mig
          sj&auml;lv... <br>
          Ifall jag gl&ouml;mmer bort hur jag gjort saker och ting s&aring; &auml;r
          det v&auml;l bra att ha det p&aring; n&auml;tet.</p>
        <p>&nbsp;</p>
        <!-- #EndEditable --> </td>
    </tr>
    <tr>
      
      <td height="13" colspan="3" valign="top" class="footer">&copy; anders enges,
        mariehamn, 2004<font color="#804040">|</font>
        <!-- #BeginDate format:Ge1m -->20.10.2004  13:46<!-- #EndDate -->
      </td>
    </tr>
    <tr>
      <td height="24" colspan="2" valign="top" class="rightborder"> <a href="#top"><img src="images/top.gif" width="20" height="14" border="0"></a>&nbsp;<img src="images/box.gif"  width="14" height="14">&nbsp;
        <?php $navList->PutHistoryList();?>
      </td>
      <td valign="middle" align="right">
        <?php $navList->PutNextPrev(); ?>
      </td>
    </tr>
    <tr>
      <td height="1"></td>
      <td width="461"></td>
      <td></td>
    </tr>
  </table>
  </center>
</body>
<!-- #EndTemplate --></html>
Listning 5.2.6.1 - sources.php
[Visa i separat fönster]

   Sidokarta mm.KällkoderTypisk sida