Jump to content

Help with this code


andy_b_1502

Recommended Posts

Hi everyone,

 

I have a display code to show my table contents. But...

 

Theres an error right near the end. (i deleted it by mistake) could someone please tell me how i can fix this at all?

 

<?PHP

include ('db.php');

$query = "SELECT * FROM companies WHERE approved > 0";
$result = mysql_query($query);
while ( $row = mysql_fetch_array($result, MYSQL_ASSOC )) {
$approved = $row['approved'];
SWITCH ($approved) {
	case 0:
		break;
	case 1:
		  ?>
             <table border=1 cellpadding=1 cellspacing=2 bordercolor=#0066FF>
             <th>Company Name</th>
             <th>Contact Name:</th>
             <th>Contact Number:</th>
             <th>Contact Email:</th>
             <th>Address 1:</th>
             <th>Address 2:</th>
             <th>Area:</th>
             <th>Postcode:</th>
			 <tr>
             <td><?PHP echo $row['company_name']; ?></td>
             <td><?PHP echo $row['contact_name']; ?></td>
             <td><?PHP echo $row['phone']; ?></td>             
             <td><?PHP echo $row['email']; ?></td>             
             <td><?PHP echo $row['street1']; ?></td>             
             <td><?PHP echo $row['street2']; ?></td>             
             <td><?PHP echo $row['location']; ?></td>             
             <td><?PHP echo $row['postcode']; ?></td><td></td><td></td><td></td></tr>
  			<?PHP
		break;	
	case 2:
		  ?>
              <table width="500" height="308" border=0 cellpadding=1 cellspacing=2 bordercolor=#0066FF>
             <th width="65">Company Name</th>
             <th width="54">Contact Name:</th>
             <th width="57">Contact Number:</th>
             <th width="54">Contact Email:</th>
             <th width="57">Address 1:</th>
             <th width="57">Address 2:</th>
             <th width="36">Area:</th>
             <th width="63">Postcode:</th>
             <th width="403">Company Description:</th>
             <th width="65">Company Logo:</th>
			 <tr>
  				<td><?PHP echo $row['company_name']; ?></td>
    	        <td><?PHP echo $row['contact_name']; ?></td>
    	        <td><?PHP echo $row['phone']; ?></td>
    	        <td><?PHP echo $row['email']; ?></td>
    	        <td><?PHP echo $row['street1']; ?></td>
    	        <td><?PHP echo $row['street2']; ?></td>
   				<td><?PHP echo $row['location']; ?></td>
   				<td><?PHP echo $row['postcode']; ?></td>
   				<td><?PHP echo $row['premiumuser_description']; ?></td>
   				<td><img src="images/thumbs/<?PHP echo $row['upload']; ?>" alt="logo"/></td>
  			</tr>
  			<?PHP
		break;	
	case 3:
		  ?>
			 <tr>
  				<td><?PHP echo $row['company_name']; ?></td>
    	        <td><?PHP echo $row['contact_name']; ?></td>
    	        <td><?PHP echo $row['phone']; ?></td>
    	        <td><?PHP echo $row['email']; ?></td>
    	        <td><?PHP echo $row['street1']; ?></td>
    	        <td><?PHP echo $row['street2']; ?></td>
   				<td><?PHP echo $row['location']; ?></td>
   				<td><?PHP echo $row['postcode']; ?></td>
   				<td><?PHP echo $row['basicpackage_description']; ?></td>
   				<td><?PHP echo $row['premiumuser_description']; ?></td>
   				<td><img src="images/thumbs/<?PHP echo $row['upload']; ?>" alt="logo"/></td>
  				</tr>
                </table>

 

Thanks in advance :)

Link to comment
Share on other sites

I posted all of the php coding. The full html/php code is this:

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
A:link {text-decoration:none;}
A:visited {text-decoration:none; color:#999;}
A:active {
text-decoration: none;
color:#FFF;
}
A:hover {text-decoration: none; color:#CCC;}
</style>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Homepage | Removalspace.com</title>
<script type="text/javascript">
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
</script>
<link href="styles/button-style.css" rel="stylesheet" type="text/css" />
<link href="newcss.css" rel="stylesheet" type="text/css" />
</head>
<body>

<div id="adbar"><button><span><em>Advertise on Removalspace</em></span></button></div>
<div id="global_wrapper">
  <div id="header"></div>
  <div id="logo"></div>
   	  <div id="menu"><button><span><em>HOME</em></span></button>
	|<button><span><em>ADVERTISE</em></span></button>|<button><span><em>REMOVALS</em></span></button>|<button><span><em>STORAGE</em></span>      	</button>
      </div>
      <div id="searchbar">	    <form method="get" action="search.php" style="background:url(images/adbar.jpg)">
      						<fieldset>
        					<button><span><em>POSTCODE FROM</em></span></button>
        					<input type="text" name="q" id="search-text" size="25" />
        					<button><span><em>POSTCODE TO</em></span></button>
        					<input type="text" name="search-text" id="search-text2" size="25" />
        					<input type="submit" name="Submit2" value="go" />
          						</fieldset>
        						</form></div>
      <div id="content"><?PHP

include ('db.php');

$query = "SELECT * FROM companies WHERE approved > 0";
$result = mysql_query($query);
while ( $row = mysql_fetch_array($result, MYSQL_ASSOC )) {
$approved = $row['approved'];
SWITCH ($approved) {
	case 0:
		break;
	case 1:
		  ?>
             <table border=1 cellpadding=1 cellspacing=2 bordercolor=#0066FF>
             <th>Company Name</th>
             <th>Contact Name:</th>
             <th>Contact Number:</th>
             <th>Contact Email:</th>
             <th>Address 1:</th>
             <th>Address 2:</th>
             <th>Area:</th>
             <th>Postcode:</th>
			 <tr>
             <td><?PHP echo $row['company_name']; ?></td>
             <td><?PHP echo $row['contact_name']; ?></td>
             <td><?PHP echo $row['phone']; ?></td>             
             <td><?PHP echo $row['email']; ?></td>             
             <td><?PHP echo $row['street1']; ?></td>             
             <td><?PHP echo $row['street2']; ?></td>             
             <td><?PHP echo $row['location']; ?></td>             
             <td><?PHP echo $row['postcode']; ?></td><td></td><td></td><td></td></tr>
  			<?PHP
		break;	
	case 2:
		  ?>
              <table width="500" height="308" border=0 cellpadding=1 cellspacing=2 bordercolor=#0066FF>
             <th width="65">Company Name</th>
             <th width="54">Contact Name:</th>
             <th width="57">Contact Number:</th>
             <th width="54">Contact Email:</th>
             <th width="57">Address 1:</th>
             <th width="57">Address 2:</th>
             <th width="36">Area:</th>
             <th width="63">Postcode:</th>
             <th width="403">Company Description:</th>
             <th width="65">Company Logo:</th>
			 <tr>
  				<td><?PHP echo $row['company_name']; ?></td>
    	        <td><?PHP echo $row['contact_name']; ?></td>
    	        <td><?PHP echo $row['phone']; ?></td>
    	        <td><?PHP echo $row['email']; ?></td>
    	        <td><?PHP echo $row['street1']; ?></td>
    	        <td><?PHP echo $row['street2']; ?></td>
   				<td><?PHP echo $row['location']; ?></td>
   				<td><?PHP echo $row['postcode']; ?></td>
   				<td><?PHP echo $row['premiumuser_description']; ?></td>
   				<td><img src="images/thumbs/<?PHP echo $row['upload']; ?>" alt="logo"/></td>
  			</tr>
  			<?PHP
		break;	
	case 3:
		  ?>
			 <tr>
  				<td><?PHP echo $row['company_name']; ?></td>
    	        <td><?PHP echo $row['contact_name']; ?></td>
    	        <td><?PHP echo $row['phone']; ?></td>
    	        <td><?PHP echo $row['email']; ?></td>
    	        <td><?PHP echo $row['street1']; ?></td>
    	        <td><?PHP echo $row['street2']; ?></td>
   				<td><?PHP echo $row['location']; ?></td>
   				<td><?PHP echo $row['postcode']; ?></td>
   				<td><?PHP echo $row['basicpackage_description']; ?></td>
   				<td><?PHP echo $row['premiumuser_description']; ?></td>
   				<td><img src="images/thumbs/<?PHP echo $row['upload']; ?>" alt="logo"/></td>
  				</tr>
                </table> 
  
 </div> 
    </div>

<div id="footer"><button><span><em>www.removalspace.com</em></span></button></div>




</body>
</html>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.