Results 1 to 2 of 2

Thread: Random pic inside of a table using PHP

  1. #1

    Random pic inside of a table using PHP

    For some reason, I can't get my random pic to work inside of a table. It works no probs on the outside. Am I missing something somewhere? Here is my code (its for a Church website I do)...
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    
    <html>
    
    <head>
    
    <title>North Gautier's Main Page</title>
    
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    
    </head>
    
    <?
    $pictures =  array("car14.jpg", "car23.jpg", "car47.jpg", "car15.jpg", "car21.jpg", 
    
    "car24.jpg", "car25.jpg", "car37.jpg", "car45.jpg", "car47.jpg", "cobra.jpg", 
    
    "joplincarshow2.jpg", "goldchevytruck.gif");
    shuffle ($pictures);
    ?>
    
    <body bgcolor="#FFFFFF" link="#0000FF">
    <?php
    include "header_new.php";
    ?>
    <table border="5" width="97%" cellpadding="0" align="center" cellspacing="0" bgcolor="#FFFFcc">
      <tr bordercolor="#FFFFCC" bgcolor="#FFFFFF"> 
        <td width="12" height="29" bgcolor="#FFFFCC"> </td>
        <td width="34" height="29" bgcolor="#FFFFCC"> <div align="center"></div></td>
        <td width="470" height="29" bgcolor="#FFFFCC"> <p> </p></td>
        <td width="28" height="29" bgcolor="#FFFFCC"> </td>
        <td colspan="2" bgcolor="#FFFFCC" height="29">
    <?php      
    echo "<img src=pics/".$pictures[1];
    ?>
    </td>
        <td width="52" height="29" bgcolor="#FFFFCC"> </td>
      </tr>
      <tr bordercolor="#FFFFCC" bgcolor="#FFFFFF"> 
        <td height="106" bgcolor="#FFFFCC"> </td>
        <td height="106" bgcolor="#FFFFCC"> </td>
        <td width="470" rowspan="6" bgcolor="#FFFFCC" cellpadding="5"> 
    <?php
    $data = file('news.txt');
    $data = array_reverse($data);
    foreach($data as $element) {
        $element = trim($element);
        $pieces = explode("|", $element);
        echo $pieces[2] . "<BR>" . "<b>Posted by " . $pieces[1] . " on " . $pieces[0] . "</b><BR><BR>";
    }
    ?>
        </td>
        <td height="106" bgcolor="#FFFFCC"> </td>
        <td colspan="2" rowspan="6" bgcolor="#FFFFCC"> <div align="center"> 
            <h3><u><em><font size="6">Latest Website Updates</font></em></u></h3>
            <p><u><em><font color="#CC0033" size="6">Don't forget to check the Calendar!</font></em></u></p>
            <p><font color="#CC0033"><u><em><font size="6">Updated 2/18/05</font></em></u></font></p>
          </div>
          <div align="center"> 
            <p><font color="#0000FF"><a href="GoForthMissions.php"> Grenada Information 
              Pamphlet.</a> <font color="#FF3333">Latest information on our Grenada 
              trip. Here is a link to info from our Pastor. Check it out!!</font></font></p>
            <p><font color="#FF3333">Click <a href="GoForthMissions.zip">here</a> 
              to Download the file. You will need Adobe Acrobat reader to view the 
              file.</font></p>
          </div>
          <div align="center"> 
            <p><font color="#0000FF"><a href="grenada_planning.php">Pics from Grenada.</a> 
              We are planning a mission trip to Grenada to help rebuild</font></p>
            <p><font color="#0000FF">houses and maybe a few churches. If you are interested 
              in contriubting, please contact us!!</font></p>
          </div>
          <div align="center"></div>
          <p align="center"><font color="#666666" size="2"><em><strong><font color="#0000FF">Music 
            and Preaching Downloads:</font></strong> </em><font color="#0000FF">Music 
            and Preaching services are available!! Click <a href="multimedia.php" target="_self"><font size="4">HERE<font size="2"> 
            </font></font></a></font></font><font color="#666666" size="2"><font color="#0000FF"> 
            to jump to the Multimedia page</font>!</font> </p></td>
        <td height="106" bgcolor="#FFFFCC"> </td>
      </tr>
      <tr bordercolor="#FFFFCC" bgcolor="#FFFFFF"> 
        <td width="12" height="106" bgcolor="#FFFFCC"> </td>
        <td width="34" height="106" bgcolor="#FFFFCC"> <div align="center"></div></td>
        <td width="28" height="106" bgcolor="#FFFFCC"> </td>
        <td width="52" height="106" bgcolor="#FFFFCC"> </td>
      </tr>
      <tr bordercolor="#FFFFCC" bgcolor="#FFFFFF"> 
        <td width="12" height="77" bgcolor="#FFFFCC"> </td>
        <td width="34" bgcolor="#FFFFCC"> <div align="center"></div></td>
        <td width="28" bgcolor="#FFFFCC"> </td>
        <td width="52" bgcolor="#FFFFCC"> </td>
      </tr>
      <tr bordercolor="#FFFFCC" bgcolor="#FFFFFF"> 
        <td width="12" height="77" bgcolor="#FFFFCC"> </td>
        <td width="34" bgcolor="#FFFFCC"> <div align="center"></div></td>
        <td width="28" bgcolor="#FFFFCC"> </td>
        <td width="52" bgcolor="#FFFFCC"> </td>
      </tr>
      <tr bordercolor="#FFFFCC" bgcolor="#FFFFFF"> 
        <td width="12" rowspan="3" bgcolor="#FFFFCC"> </td>
        <td width="34" height="177" bgcolor="#FFFFCC"> <div align="center"></div></td>
        <td width="28" bgcolor="#FFFFCC"> </td>
        <td width="52" rowspan="3" bgcolor="#FFFFCC"> </td>
      </tr>
      <tr> 
        <td width="34" height="26" bordercolor="#FFFFCC" bgcolor="#FFFFCC"> </td>
        <td width="28" height="26" bordercolor="#FFFFCC" bgcolor="#FFFFCC"> </td>
      </tr>
      <tr> 
        <td colspan="5" rowspan="4" bordercolor="#FFFFCC" bgcolor="#FFFFCC"> <div align="center"> 
            <p align="center"><font color="#000000"><strong><em>Current Conditions 
              in Gautier are:</em></strong></font></p>
            <p align="center"><a href="http://www.wunderground.com/US/MS/Ga...html"> 
              <img src="http://banners.wunderground.com/bann...tier.gif"
    alt="Click for Gautier, Mississippi Forecast" height=60 width=468></a> </p>
            <p> </p>
          </div></td>
      </tr>
      <tr bordercolor="#FFFFCC" bgcolor="#FFFFFF"> 
        <td width="12" height="22" bgcolor="#FFFFCC"> </td>
        <td width="52" height="22" bgcolor="#FFFFCC"> </td>
      </tr>
      <tr bordercolor="#FFFFCC" bgcolor="#FFFFFF"> 
        <td width="12" height="20" bgcolor="#FFFFCC"> </td>
        <td width="52" height="20" bgcolor="#FFFFCC"> </td>
      </tr>
      <tr bordercolor="#FFFFCC" bgcolor="#FFFFFF"> 
        <td width="12" height="76" bgcolor="#FFFFCC"> </td>
        <td width="52" height="76" bgcolor="#FFFFCC"> </td>
      </tr>
      <tr bordercolor="#FFFFCC" bgcolor="#FFFFCC"> 
        <td height="21" colspan="7" bgcolor="#FFFFCC"> </td>
      </tr>
    </table>
    
    <table width="97%" height="19"  align="center" border="5" cellpadding="0" cellspacing="0">
      <tr bgcolor="#FFFFCC"> 
        <td width="9%" height="19"> 
          <div align="center"><font size="1"><a href="salvation.php" target="_self">Salvation</a></font></div></td>
    
        <td width="11%"> 
          <div align="center"><font size="1"><a href="vision.php" target="_self">Our 
    
            Vision</a></font></div></td>
    
        <td width="9%"> 
          <div align="center"><font size="1"><a href="about_us.php" target="_self">About 
    
            Us</a></font></div></td>
    
        <td width="9%"> 
          <div align="center"><font size="1"><a href="ministries.php" target="_self">Ministries</a></font></div></td>
    
        <td width="20%"> 
          <div align="center"><font size="1"><a href="missions_community.php" target="_self">Missions 
    
            & Community</a></font></div></td>
    
        <td width="10%"> 
          <div align="center"><font size="1"><a href="calendar.htm" target="_self">Calendar</a></font></div></td>
    
        <td width="18%"> 
          <div align="center"><font size="1"><a href="http://www.mapquest.com/maps/map.adp...=Get+Map" target="_self">Location 
    
            & Directions</a></font></div></td>
    
        <td width="14%"> 
          <div align="center"><font size="1"><a href="prayerlist.php" target="_self">Prayer 
    
            Requests</a></font></div></td>
    
      </tr>
    
    </table>
    
    <p align="center">©2004 North Gautier Baptist Church All Rights Reserved</p>
    
    <?php
    
    /* counter */
    
    $datei = fopen("countlog.txt","r"); //opens countlog.txt to read
    
    $count = fgets($datei,1000);
    
    fclose($datei);
    
    $count=$count + 1 ;
    
    echo "<CENTER><FONT SIZE=\"3\" FACE=\"arial, verdana, helvetica\">You are vistor no.</FONT></CENTER>" ;
    
    echo "<CENTER><FONT SIZE=\"3\" FACE=\"arial, verdana, helvetica\">$count</FONT></CENTER>" ;
    
    echo "\n<br>" ;
    
    echo "<CENTER><FONT SIZE=\"3\" FACE=\"arial, verdana, helvetica\">Since January of 2004.</FONT></CENTER>" ;
    
    $datei = fopen("countlog.txt","w"); // opens to write and deletes the old count
    
    fwrite($datei, $count);
    
    fclose($datei); 
    
    ?> 
    <?
    //--------------------------------------------------------logging php below
    // Get the name of the file we are logging
    $fileName="index.php";
    $fileSize="11802";
    // Get Web site visitor's CLF information
    $host=$_SERVER['REMOTE_ADDR'];
    
    $ident=$_SERVER['REMOTE_IDENT'];
    echo $ident;
    $auth=$_SERVER['REMOTE_USER'];
    
    $timeStamp=date("d/M/Y:H:i:s O");
    
    $reqType=$_SERVER['REQUEST_METHOD'];
    
    $servProtocol=$_SERVER['SERVER_PROTOCOL'];
    
    $statusCode="200";
    
    // Add dashes to empty variables (as per the specifications)
    if ($host==""){ $host="-"; }
    if ($ident==""){ $ident="-"; }
    if ($auth==""){ $auth="-"; }
    if ($reqType==""){ $reqType="-"; }
    if ($servProtocol==""){ $servProtocol="-"; }
    // Create CLF formatted string
    $clfString=$host." ".$ident." ".$auth." [".$timeStamp."] \"".$reqType." /".$fileName." ".$servProtocol."\" ".$statusCode." ".$fileSize."\r\n";
    
    
    // Get current logfile name using today's date
    $logPath="/mylogs/";
    $logFile=$logPath."weblog-".date("mdy").".log"; 
    
    // Check to see whether log file exists
    if (file_exists($logFile)){
    // If YES, Open Existing Log File
    $fileWrite = fopen($logFile,"a");}
    else {
    // If NO, Create a New Log File
    $fileWrite = fopen($logFile,"w"); }
    
    // Create a "Write" File Lock
    flock($fileWrite, LOCK_SH);
    
    //Finally, we write the contents of our entry:
    // Write CLF entry
    fwrite($fileWrite,$clfString);
    // Relinquish File Lock
    flock($fileWrite, LOCK_UN);
    // Close Log File
    fclose($fileWrite);
    //---------------------------------------------------------------------logging php above
    ?>
    
    <p align="center"><a href="mailto:webmaster@northgautierbaptist.org">webmaster@northgautierbaptist.org</a></p>
    
    <p> </p>
    
    </body>
    
    </html>

  2. #2

    Re:Random pic inside of a table using PHP

    Ok, think I got it worked out. Here is the fix
    Code:
    <?php
    echo '<align="center"><img src="pics/';
      echo $pictures[1];
      echo '">';
    ?>
    Obviously, this goes in the table section where it references the $pictures array. By the way, the cars are for another section of the site, I just used it to test the code (in case your wondering).

Similar Threads

  1. redirect traffic inside NAt to appear to come from outside.
    By frostbolt in forum Linux - Hardware, Networking & Security
    Replies: 3
    Last Post: 11-09-2010, 04:08 PM
  2. Bioshock - possible spoilers inside
    By Enolij in forum Windows - General Topics
    Replies: 1
    Last Post: 10-18-2007, 11:42 AM
  3. CONTEST!!! See INSIDE FOR MORE INFO!!! :D
    By in forum Linux - Software, Applications & Programming
    Replies: 13
    Last Post: 12-03-2004, 10:03 AM
  4. Random reboot
    By CP in forum Linux - General Topics
    Replies: 5
    Last Post: 03-04-2004, 11:32 PM
  5. I seek the treasure inside the oyster!
    By Aaron_Adams in forum Linux - Software, Applications & Programming
    Replies: 7
    Last Post: 12-01-2001, 11:54 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •