Parse error - $

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
andy_hall_4
Forum Newbie
Posts: 4
Joined: Thu Mar 23, 2006 9:55 am

Parse error - $

Post by andy_hall_4 »

I have progressed a little with my code for displaying addresses from a database however I have come stuck again. When I execute a search of the database I now get the following message:

Code: Select all

Parse error: parse error, unexpected $ in /home/digslis/public_html/test3.php on line 231
Now the php worked, I got a lovely tabled display of all of the results matching the search box text from the page that calls this file. The problem started when I tried to get clever and put in a few if/else clauses so that if $digsad2 was blank then it would not print a blank line. I also did the same with $pic 1 - 5 so that if there was no link in the database then no link would show on screen. However I seem to have missed something. I have now been looking at the code for two days and can't see what is the problem. Please could someone advise.


Code: Select all

<?php 
$search="$HTTP_POST_VARS[search]"; 
$username="digslis_root"; 
$password="******"; 
$database="digslis_addresses"; 
mysql_connect("localhost",$username,$password); 
@mysql_select_db($database) or die( "Unable to select database please use your browser's back key and try again. If this problem persists please try again later"); 
$query="SELECT *  FROM `table` WHERE `digstown` LIKE '$search' OR `nearest` LIKE '$search'"; 
$result=mysql_query($query)or die (mysql_error()); 
$num=mysql_num_rows($result); 
mysql_close(); 
echo "<b><center>Search Results</center></b><br>"; 
echo "Total number of records found = $num"; 
$i=0; 
if ($num==0) { 
    echo "No records found"; 
} else { 
    while ($i < $num) 
        { 
        $index=mysql_result($result,$i,"index"); 
        $title=mysql_result($result,$i,"title"); 
        $forename=mysql_result($result,$i,"forename"); 
        $surname=mysql_result($result,$i,"surname"); 
        $suffix=mysql_result($result,$i,"suffix"); 
        $digsad1=mysql_result($result,$i,"digsad1"); 
        $digsad2=mysql_result($result,$i,"digsad2"); 
        $digstown=mysql_result($result,$i,"digstown"); 
        $digscounty=mysql_result($result,$i,"digscounty"); 
        $digspostcode=mysql_result($result,$i,"digspostcode"); 
        $digstele=mysql_result($result,$i,"digstele"); 
        $description=mysql_result($result,$i,"description"); 
        $pic1=mysql_result($result,$i,"pic1"); 
        $pic2=mysql_result($result,$i,"pic2"); 
        $pic3=mysql_result($result,$i,"pic3"); 
        $pic4=mysql_result($result,$i,"pic4"); 
        $pic5=mysql_result($result,$i,"pic5"); 
        $distance=mysql_result($result,$i,"distance"); 
        $cost=mysql_result($result,$i,"cost"); 
        $nearest=mysql_result($result,$i,"nearest"); 
        $contactad1=mysql_result($result,$i,"contactad1"); 
        $contactad2=mysql_result($result,$i,"contactad2"); 
        $contacttown=mysql_result($result,$i,"contacttown"); 
        $contactcounty=mysql_result($result,$i,"contactcounty"); 
        $contactpostcode=mysql_result($result,$i,"contactpostcode"); 
        echo "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"; 
        echo "  <tr bgcolor=\"#BBE1E3\"><td colspan=\"5\">&nbsp;</td></tr><tr>"; 
        echo "    <td colspan=\"2\">$title $forename $surname </td>"; 
        echo "    <td width=\"17%\">&nbsp;</td>"; 
        echo "    <td width=\"17%\">&nbsp;</td>"; 
        echo "    <td width=\"28%\">Nearest Theatre:$nearest </td>"; 
        echo "  </tr>"; 
        echo "  <tr>"; 
        echo "    <td width=\"18%\">$digsad1</td>"; 
        echo "    <td width=\"20%\">&nbsp;</td>"; 
        echo "    <td>&nbsp;</td>"; 
        echo "    <td>&nbsp;</td>"; 
        echo "    <td>Distance to theatre:$distance </td>"; 
        echo "  </tr>"; 
        echo "  <tr>"; 
        if ($digsad2==" ") { 
            echo "    <td>&nbsp;</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "    <td>Cost:$cost</td>"; 
            echo "  </tr>"; 
            echo "  <tr>"; 
            echo "    <td>$digstown</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "  </tr>"; 
            echo "  <tr>"; 
            echo "    <td>$digscounty</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "  </tr>"; 
            echo "  <tr>"; 
            echo "    <td>$digspostcode</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "  </tr>"; 
            echo "  <tr>"; 
            echo "    <td>$digstele</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "  </tr>"; 
            echo "  <tr>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "  </tr>"; 
            echo "  <tr>"; 
            echo "    <td colspan=\"5\">Description: $description</td>"; 
            echo "  </tr>"; 
            echo "  <tr>"; 
            echo "    <td colspan=\"5\">&nbsp;</td>"; 
            echo "  </tr>"; 
            if ($pic1==" ") { 
                echo "  <tr>"; 
                echo "    <td colspan=\"5\">&nbsp;</td>"; 
                echo "  </tr>"; 
                echo "</table>"; 
                $i=$i+1; 
            } else { 
                echo "  <tr>"; 
                echo "    <td colspan=\"5\"><a href=$pic1>Picture 1</a>"; 
                if ($pic2==" ") { 
                    echo "</td>"; 
                    echo "</tr>"; 
                    } else { 
                    echo "   <a href=$pic2>Picture 2</a>"; 
                    if ($pic3==" ") { 
                        echo "</td>"; 
                        echo "</tr>"; 
                        } else { 
                        echo "   <a href=$pic3>Picture 3</a>"; 
                        if ($pic4==" ") { 
                            echo "</td>"; 
                            echo "</tr>"; 
                            } else { 
                            echo "   <a href=$pic4>Picture 4</a>"; 
                            if ($pic5==" ") { 
                                echo "</td>"; 
                                echo "</tr>"; 
                                } else { 
                                echo "   <a href=$pic5>Picture 5</a>"; 
                                echo "</td>"; 
                                echo "  </tr>";} 
            echo "  <tr>"; 
            echo "    <td colspan=\"5\">&nbsp;</td>"; 
            echo "  </tr>"; 
            echo "</table>"; 
            $i=$i+1; 
            }}}} 
           } else { 
            echo "    <td>$digsad2</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "    <td>Cost:$cost</td>"; 
            echo "  </tr>"; 
            echo "  <tr>"; 
            echo "    <td>$digstown</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "  </tr>"; 
            echo "  <tr>"; 
            echo "    <td>$digscounty</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "  </tr>"; 
            echo "  <tr>"; 
            echo "    <td>$digspostcode</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "  </tr>"; 
            echo "  <tr>"; 
            echo "    <td>$digstele</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "  </tr>"; 
            echo "  <tr>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "  </tr>"; 
            echo "  <tr>"; 
            echo "    <td colspan=\"5\">Description: $description</td>"; 
            echo "  </tr>"; 
            echo "  <tr>"; 
            echo "    <td colspan=\"5\">&nbsp;</td>"; 
            echo "  </tr>"; 
            if ($pic1==" ") { 
                echo "  <tr>"; 
                echo "    <td colspan=\"5\">&nbsp;</td>"; 
                echo "  </tr>"; 
                echo "</table>"; 
                $i=$i+1; 
            } else { 
                echo "  <tr>"; 
                echo "    <td colspan=\"5\"><a href=$pic1>Picture 1</a>"; 
                if ($pic2==" ") { 
                    echo "</td>"; 
                    echo "</tr>"; 
                    } else { 
                    echo "   <a href=$pic2>Picture 2</a>"; 
                    if ($pic3==" ") { 
                        echo "</td>"; 
                        echo "</tr>"; 
                        } else { 
                        echo "   <a href=$pic3>Picture 3</a>"; 
                        if ($pic4==" ") { 
                            echo "</td>"; 
                            echo "</tr>"; 
                            } else { 
                            echo "   <a href=$pic4>Picture 4</a>"; 
                            if ($pic5==" ") { 
                                echo "</td>"; 
                                echo "</tr>"; 
                                } else { 
                                echo "   <a href=$pic5>Picture 5</a>"; 
                                echo "</td>"; 
                                echo "  </tr>";} 
            echo "  <tr>"; 
            echo "    <td colspan=\"5\">&nbsp;</td>"; 
            echo "  </tr>"; 
            echo "</table>"; 
            $i=$i+1; 
            }}}} 
} 
?>
Many thanks, Andy Hall
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

Your missing a } someplace most likely. That is the most common cause of this error.
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

Code: Select all

$i=$i+1;  
            }}}}
that's very bad practice :P

If you indent your code properly you can see where they match up at a glance
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

You didn't close the while loop and you didn't close the first else. You may want to look at ways to clean that code up a bit to get rid of all those if-else's. Here is your code cleaned up a bit...

Code: Select all

<?php 
$search="$HTTP_POST_VARS[search]"; 
$username="digslis_root"; 
$password="******"; 
$database="digslis_addresses"; 
mysql_connect("localhost",$username,$password); 
@mysql_select_db($database) or die( "Unable to select database please use your browser's back key and try again. If this problem persists please try again later"); 
$query="SELECT *  FROM `table` WHERE `digstown` LIKE '$search' OR `nearest` LIKE '$search'"; 
$result=mysql_query($query)or die (mysql_error()); 
$num=mysql_num_rows($result); 
mysql_close(); 
echo "<b><center>Search Results</center></b><br>"; 
echo "Total number of records found = $num"; 
$i=0; 
if ($num==0) { 
    echo "No records found"; 
} else { 
    while ($i < $num) 
    { 
        $index=mysql_result($result,$i,"index"); 
        $title=mysql_result($result,$i,"title"); 
        $forename=mysql_result($result,$i,"forename"); 
        $surname=mysql_result($result,$i,"surname"); 
        $suffix=mysql_result($result,$i,"suffix"); 
        $digsad1=mysql_result($result,$i,"digsad1"); 
        $digsad2=mysql_result($result,$i,"digsad2"); 
        $digstown=mysql_result($result,$i,"digstown"); 
        $digscounty=mysql_result($result,$i,"digscounty"); 
        $digspostcode=mysql_result($result,$i,"digspostcode"); 
        $digstele=mysql_result($result,$i,"digstele"); 
        $description=mysql_result($result,$i,"description"); 
        $pic1=mysql_result($result,$i,"pic1"); 
        $pic2=mysql_result($result,$i,"pic2"); 
        $pic3=mysql_result($result,$i,"pic3"); 
        $pic4=mysql_result($result,$i,"pic4"); 
        $pic5=mysql_result($result,$i,"pic5"); 
        $distance=mysql_result($result,$i,"distance"); 
        $cost=mysql_result($result,$i,"cost"); 
        $nearest=mysql_result($result,$i,"nearest"); 
        $contactad1=mysql_result($result,$i,"contactad1"); 
        $contactad2=mysql_result($result,$i,"contactad2"); 
        $contacttown=mysql_result($result,$i,"contacttown"); 
        $contactcounty=mysql_result($result,$i,"contactcounty"); 
        $contactpostcode=mysql_result($result,$i,"contactpostcode"); 
        echo "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"; 
        echo "  <tr bgcolor=\"#BBE1E3\"><td colspan=\"5\">&nbsp;</td></tr><tr>"; 
        echo "    <td colspan=\"2\">$title $forename $surname </td>"; 
        echo "    <td width=\"17%\">&nbsp;</td>"; 
        echo "    <td width=\"17%\">&nbsp;</td>"; 
        echo "    <td width=\"28%\">Nearest Theatre:$nearest </td>"; 
        echo "  </tr>"; 
        echo "  <tr>"; 
        echo "    <td width=\"18%\">$digsad1</td>"; 
        echo "    <td width=\"20%\">&nbsp;</td>"; 
        echo "    <td>&nbsp;</td>"; 
        echo "    <td>&nbsp;</td>"; 
        echo "    <td>Distance to theatre:$distance </td>"; 
        echo "  </tr>"; 
        echo "  <tr>"; 
        if ($digsad2==" ") { 
            echo "    <td>&nbsp;</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "    <td>Cost:$cost</td>"; 
            echo "  </tr>"; 
            echo "  <tr>"; 
            echo "    <td>$digstown</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "  </tr>"; 
            echo "  <tr>"; 
            echo "    <td>$digscounty</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "  </tr>"; 
            echo "  <tr>"; 
            echo "    <td>$digspostcode</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "  </tr>"; 
            echo "  <tr>"; 
            echo "    <td>$digstele</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "  </tr>"; 
            echo "  <tr>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "  </tr>"; 
            echo "  <tr>"; 
            echo "    <td colspan=\"5\">Description: $description</td>"; 
            echo "  </tr>"; 
            echo "  <tr>"; 
            echo "    <td colspan=\"5\">&nbsp;</td>"; 
            echo "  </tr>"; 
            if ($pic1==" ") { 
                echo "  <tr>"; 
                echo "    <td colspan=\"5\">&nbsp;</td>"; 
                echo "  </tr>"; 
                echo "</table>"; 
                $i=$i+1; 
            } else { 
                echo "  <tr>"; 
                echo "    <td colspan=\"5\"><a href=$pic1>Picture 1</a>"; 
                if ($pic2==" ") { 
                    echo "</td>"; 
                    echo "</tr>"; 
                } else { 
                    echo "   <a href=$pic2>Picture 2</a>"; 
                    if ($pic3==" ") { 
                        echo "</td>"; 
                        echo "</tr>"; 
					} else { 
						echo "   <a href=$pic3>Picture 3</a>"; 
						if ($pic4==" ") { 
							echo "</td>"; 
							echo "</tr>"; 
						} else { 
							echo "   <a href=$pic4>Picture 4</a>"; 
							if ($pic5==" ") { 
								echo "</td>"; 
								echo "</tr>"; 
							} else { 
								echo "   <a href=$pic5>Picture 5</a>"; 
								echo "</td>"; 
								echo "  </tr>";
							} 
							echo "  <tr>"; 
							echo "    <td colspan=\"5\">&nbsp;</td>"; 
							echo "  </tr>"; 
							echo "</table>"; 
							$i=$i+1; 
						}
					}
				}
			} 
        } else { 
            echo "    <td>$digsad2</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "    <td>Cost:$cost</td>"; 
            echo "  </tr>"; 
            echo "  <tr>"; 
            echo "    <td>$digstown</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "  </tr>"; 
            echo "  <tr>"; 
            echo "    <td>$digscounty</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "  </tr>"; 
            echo "  <tr>"; 
            echo "    <td>$digspostcode</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "  </tr>"; 
            echo "  <tr>"; 
            echo "    <td>$digstele</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "  </tr>"; 
            echo "  <tr>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "    <td>&nbsp;</td>"; 
            echo "  </tr>"; 
            echo "  <tr>"; 
            echo "    <td colspan=\"5\">Description: $description</td>"; 
            echo "  </tr>"; 
            echo "  <tr>"; 
            echo "    <td colspan=\"5\">&nbsp;</td>"; 
            echo "  </tr>"; 
            if ($pic1==" ") { 
                echo "  <tr>"; 
                echo "    <td colspan=\"5\">&nbsp;</td>"; 
                echo "  </tr>"; 
                echo "</table>"; 
                $i=$i+1; 
            } else { 
                echo "  <tr>"; 
                echo "    <td colspan=\"5\"><a href=$pic1>Picture 1</a>"; 
                if ($pic2==" ") { 
                    echo "</td>"; 
                    echo "</tr>"; 
                } else { 
                    echo "   <a href=$pic2>Picture 2</a>"; 
                    if ($pic3==" ") { 
                        echo "</td>"; 
                        echo "</tr>"; 
                    } else { 
                        echo "   <a href=$pic3>Picture 3</a>"; 
                        if ($pic4==" ") { 
                            echo "</td>"; 
                            echo "</tr>"; 
                        } else { 
                            echo "   <a href=$pic4>Picture 4</a>"; 
                            if ($pic5==" ") { 
                                echo "</td>"; 
                                echo "</tr>"; 
                            } else { 
                                echo "   <a href=$pic5>Picture 5</a>"; 
                                echo "</td>"; 
                                echo "  </tr>";
							} 
				            echo "  <tr>"; 
				            echo "    <td colspan=\"5\">&nbsp;</td>"; 
				            echo "  </tr>"; 
				            echo "</table>"; 
				            $i=$i+1; 
						}
					}
				}
			}
		}
	}
}
?>
andy_hall_4
Forum Newbie
Posts: 4
Joined: Thu Mar 23, 2006 9:55 am

Post by andy_hall_4 »

Thank you to everyone who replied.

I have changed the code a little as when I ran it I found that it just continued to display the first record because I didn't have the $i=$i+1 in the right place! So here is the code, in case it it of benifit for others. I still have some formatting issues that I would like to address to tidy upi the appearance of the final output but I am well on my way. Considering I knew nothing about PHP four weeks ago I think that I have progressed very well. And it is thanks to the people here on this forum that I have been able to do it so quick. So many thanks to one and all.


Here is the code as it satands at the moment....

Code: Select all

<?php  
$search="$HTTP_POST_VARS[search]";  
$username="digslis_root";  
$password="********";  
$database="digslis_addresses";  
mysql_connect("localhost",$username,$password);  
@mysql_select_db($database) or die( "Unable to select database please use your browser's back key and try again. If this problem persists please try again later");  
$query="SELECT *  FROM `table` WHERE `digstown` LIKE '$search' OR `nearest` LIKE '$search'";  
$result=mysql_query($query)or die (mysql_error());  
$num=mysql_num_rows($result);  
mysql_close();  
echo "<b><center>Search Results</center></b><br>";  
echo "Total number of records found = $num";  
$i=0;  
if ($num==0) {  
    echo "No records found";  
} else {  
    while ($i < $num)  
    {  
        $index=mysql_result($result,$i,"index");  
        $title=mysql_result($result,$i,"title");  
        $forename=mysql_result($result,$i,"forename");  
        $surname=mysql_result($result,$i,"surname");  
        $suffix=mysql_result($result,$i,"suffix");  
        $digsad1=mysql_result($result,$i,"digsad1");  
        $digsad2=mysql_result($result,$i,"digsad2");  
        $digstown=mysql_result($result,$i,"digstown");  
        $digscounty=mysql_result($result,$i,"digscounty");  
        $digspostcode=mysql_result($result,$i,"digspostcode");  
        $digstele=mysql_result($result,$i,"digstele");  
        $description=mysql_result($result,$i,"description");  
        $pic1=mysql_result($result,$i,"pic1");  
        $pic2=mysql_result($result,$i,"pic2");  
        $pic3=mysql_result($result,$i,"pic3");  
        $pic4=mysql_result($result,$i,"pic4");  
        $pic5=mysql_result($result,$i,"pic5");  
        $distance=mysql_result($result,$i,"distance");  
        $cost=mysql_result($result,$i,"cost");  
        $nearest=mysql_result($result,$i,"nearest");  
        $contactad1=mysql_result($result,$i,"contactad1");  
        $contactad2=mysql_result($result,$i,"contactad2");  
        $contacttown=mysql_result($result,$i,"contacttown");  
        $contactcounty=mysql_result($result,$i,"contactcounty");  
        $contactpostcode=mysql_result($result,$i,"contactpostcode");  
        echo "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";  
        echo "  <tr bgcolor=\"#BBE1E3\"><td colspan=\"5\">&nbsp;</td></tr><tr>";  
        echo "    <td colspan=\"2\">$title $forename $surname </td>";  
        echo "    <td width=\"17%\">&nbsp;</td>";  
        echo "    <td width=\"17%\">&nbsp;</td>";  
        echo "    <td width=\"28%\">Nearest Theatre:$nearest </td>";  
        echo "  </tr>";  
        echo "  <tr>";  
        echo "    <td width=\"18%\">$digsad1</td>";  
        echo "    <td width=\"20%\">&nbsp;</td>";  
        echo "    <td>&nbsp;</td>";  
        echo "    <td>&nbsp;</td>";  
        echo "    <td>Distance to theatre:$distance </td>";  
        echo "  </tr>";  
        echo "  <tr>";  
        if ($digsad2=="") {  
            echo "    <td>&nbsp;</td>";  
            echo "    <td>&nbsp;</td>";  
            echo "    <td>&nbsp;</td>";  
            echo "    <td>&nbsp;</td>";  
            echo "    <td>Cost:$cost</td>";  
            echo "  </tr>";  
            echo "  <tr>";  
            echo "    <td>$digstown</td>";  
            echo "    <td>&nbsp;</td>";  
            echo "    <td>&nbsp;</td>";  
            echo "    <td>&nbsp;</td>";  
            echo "    <td>&nbsp;</td>";  
            echo "  </tr>";  
            echo "  <tr>";  
            echo "    <td>$digscounty</td>";  
            echo "    <td>&nbsp;</td>";  
            echo "    <td>&nbsp;</td>";  
            echo "    <td>&nbsp;</td>";  
            echo "    <td>&nbsp;</td>";  
            echo "  </tr>";  
            echo "  <tr>";  
            echo "    <td>$digspostcode</td>";  
            echo "    <td>&nbsp;</td>";  
            echo "    <td>&nbsp;</td>";  
            echo "    <td>&nbsp;</td>";  
            echo "    <td>&nbsp;</td>";  
            echo "  </tr>";  
            echo "  <tr>";  
            echo "    <td>$digstele</td>";  
            echo "    <td>&nbsp;</td>";  
            echo "    <td>&nbsp;</td>";  
            echo "    <td>&nbsp;</td>";  
            echo "    <td>&nbsp;</td>";  
            echo "  </tr>";  
            echo "  <tr>";  
            echo "    <td>&nbsp;</td>";  
            echo "    <td>&nbsp;</td>";  
            echo "    <td>&nbsp;</td>";  
            echo "    <td>&nbsp;</td>";  
            echo "    <td>&nbsp;</td>";  
            echo "  </tr>";  
            echo "  <tr>";  
            echo "    <td colspan=\"5\">Description: $description</td>";  
            echo "  </tr>";  
            echo "  <tr>";  
            echo "    <td colspan=\"5\">&nbsp;</td>";  
            echo "  </tr>";  
            if ($pic1=="") {  
                echo "  <tr>";  
                echo "    <td colspan=\"5\">&nbsp;</td>";  
                echo "  </tr>";  
                echo "</table>";  
                $i=$i+1;  
            } else {  
                echo "  <tr>";  
                echo "    <td colspan=\"5\"><a href=$pic1>Picture 1</a>";  
                if ($pic2=="") {  
                    echo "</td>";  
                    echo "</tr>";  
                } else {  
                    echo "   <a href=$pic2>Picture 2</a>";  
                    if ($pic3=="") {  
                        echo "</td>";  
                        echo "</tr>";  
                    } else {  
                        echo "   <a href=$pic3>Picture 3</a>";  
                        if ($pic4=="") {  
                            echo "</td>";  
                            echo "</tr>";  
                        } else {  
                            echo "   <a href=$pic4>Picture 4</a>";  
                            if ($pic5=="") {  
                                echo "</td>";  
                                echo "</tr>";  
                            } else {  
                                echo "   <a href=$pic5>Picture 5</a>";  
                                echo "</td>";  
                                echo "  </tr>"; 
                            }  
                        } 
                    } 
                } 
            }  
        echo "  <tr>";  
        echo "    <td colspan=\"5\">&nbsp;</td>";  
        echo "  </tr>";  
        echo "</table>";  
        $i=$i+1; 
        } else {  
            echo "    <td>$digsad2</td>";  
            echo "    <td>&nbsp;</td>";  
            echo "    <td>&nbsp;</td>";  
            echo "    <td>&nbsp;</td>";  
            echo "    <td>Cost:$cost</td>";  
            echo "  </tr>";  
            echo "  <tr>";  
            echo "    <td>$digstown</td>";  
            echo "    <td>&nbsp;</td>";  
            echo "    <td>&nbsp;</td>";  
            echo "    <td>&nbsp;</td>";  
            echo "    <td>&nbsp;</td>";  
            echo "  </tr>";  
            echo "  <tr>";  
            echo "    <td>$digscounty</td>";  
            echo "    <td>&nbsp;</td>";  
            echo "    <td>&nbsp;</td>";  
            echo "    <td>&nbsp;</td>";  
            echo "    <td>&nbsp;</td>";  
            echo "  </tr>";  
            echo "  <tr>";  
            echo "    <td>$digspostcode</td>";  
            echo "    <td>&nbsp;</td>";  
            echo "    <td>&nbsp;</td>";  
            echo "    <td>&nbsp;</td>";  
            echo "    <td>&nbsp;</td>";  
            echo "  </tr>";  
            echo "  <tr>";  
            echo "    <td>$digstele</td>";  
            echo "    <td>&nbsp;</td>";  
            echo "    <td>&nbsp;</td>";  
            echo "    <td>&nbsp;</td>";  
            echo "    <td>&nbsp;</td>";  
            echo "  </tr>";  
            echo "  <tr>";  
            echo "    <td>&nbsp;</td>";  
            echo "    <td>&nbsp;</td>";  
            echo "    <td>&nbsp;</td>";  
            echo "    <td>&nbsp;</td>";  
            echo "    <td>&nbsp;</td>";  
            echo "  </tr>";  
            echo "  <tr>";  
            echo "    <td colspan=\"5\">Description: $description</td>";  
            echo "  </tr>";  
            echo "  <tr>";  
            echo "    <td colspan=\"5\">&nbsp;</td>";  
            echo "  </tr>";  
            if ($pic1=="") {  
                echo "  <tr>";  
                echo "    <td colspan=\"5\">&nbsp;</td>";  
                echo "  </tr>";  
                echo "</table>";  
                $i=$i+1;  
            } else {  
                echo "  <tr>";  
                echo "    <td colspan=\"5\"><a href=$pic1>Picture 1</a>";  
                if ($pic2=="") {  
                    echo "</td>";  
                    echo "</tr>";  
                } else {  
                    echo "   <a href=$pic2>Picture 2</a>";  
                    if ($pic3=="") {  
                        echo "</td>";  
                        echo "</tr>";  
                    } else {  
                        echo "   <a href=$pic3>Picture 3</a>";  
                        if ($pic4=="") {  
                            echo "</td>";  
                            echo "</tr>";  
                        } else {  
                            echo "   <a href=$pic4>Picture 4</a>";  
                            if ($pic5=="") {  
                                echo "</td>";  
                                echo "</tr>";  
                            } else {  
                                echo "   <a href=$pic5>Picture 5</a>";  
                                echo "</td>";  
                                echo "  </tr>"; 
                            }  
                            echo "  <tr>";  
                            echo "    <td colspan=\"5\">&nbsp;</td>";  
                            echo "  </tr>";  
                            echo "</table>";  
                            $i=$i+1;  
                        } 
                    } 
                } 
            }
        echo "  <tr>";  
        echo "    <td colspan=\"5\">&nbsp;</td>";  
        echo "  </tr>";  
        echo "</table>";  
        $i=$i+1;  
        } 
    } 
} 
?>
Please feel free to pick out any bits that you might feel are useful, although being a beginner I'm sure you're all well past the stage that I am!

thank you,

Andy Hall
Post Reply