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)...
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <title>North Gautier's Main Page</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    $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">
    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">
    echo "<img src=pics/".$pictures[1];
        <td width="52" height="29" bgcolor="#FFFFCC"> </td>
      <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"> 
    $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 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 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="">here</a> 
              to Download the file. You will need Adobe Acrobat reader to view the 
          <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 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 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 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 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 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>
        <td width="34" height="26" bordercolor="#FFFFCC" bgcolor="#FFFFCC"> </td>
        <td width="28" height="26" bordercolor="#FFFFCC" bgcolor="#FFFFCC"> </td>
        <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=""> 
              <img src=""
    alt="Click for Gautier, Mississippi Forecast" height=60 width=468></a> </p>
            <p> </p>
      <tr bordercolor="#FFFFCC" bgcolor="#FFFFFF"> 
        <td width="12" height="22" bgcolor="#FFFFCC"> </td>
        <td width="52" height="22" bgcolor="#FFFFCC"> </td>
      <tr bordercolor="#FFFFCC" bgcolor="#FFFFFF"> 
        <td width="12" height="20" bgcolor="#FFFFCC"> </td>
        <td width="52" height="20" bgcolor="#FFFFCC"> </td>
      <tr bordercolor="#FFFFCC" bgcolor="#FFFFFF"> 
        <td width="12" height="76" bgcolor="#FFFFCC"> </td>
        <td width="52" height="76" bgcolor="#FFFFCC"> </td>
      <tr bordercolor="#FFFFCC" bgcolor="#FFFFCC"> 
        <td height="21" colspan="7" bgcolor="#FFFFCC"> </td>
    <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 
        <td width="9%"> 
          <div align="center"><font size="1"><a href="about_us.php" target="_self">About 
        <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="" target="_self">Location 
            & Directions</a></font></div></td>
        <td width="14%"> 
          <div align="center"><font size="1"><a href="prayerlist.php" target="_self">Prayer 
    <p align="center">©2004 North Gautier Baptist Church All Rights Reserved</p>
    /* counter */
    $datei = fopen("countlog.txt","r"); //opens countlog.txt to read
    $count = fgets($datei,1000);
    $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);
    //--------------------------------------------------------logging php below
    // Get the name of the file we are logging
    // Get Web site visitor's CLF information
    echo $ident;
    $timeStamp=date("d/M/Y:H:i:s O");
    // 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
    // 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
    // Relinquish File Lock
    flock($fileWrite, LOCK_UN);
    // Close Log File
    //---------------------------------------------------------------------logging php above
    <p align="center"><a href=""></a></p>
    <p> </p>

  2. #2

    Re:Random pic inside of a table using PHP

    Ok, think I got it worked out. Here is the fix
    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
    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


Posting Permissions

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