I have a php script that echoes results from a search. Generally I have no problem getting the results in a table but for some reason I can't get these scripts to do that. I figure its a small error. I'm going to put in the code but if you want to just suggest a good editor (as I am new to php) that would be helpful. Thanks.

<?php
  if(isset($_POST['submit'])){
  if(isset($_GET['go'])){
  if(preg_match("/^[  a-zA-Z0-9]+/", $_POST['search'])){
  $search=$_POST['search'];
  
  $db=mysql_connect  ("connection info") or die ('I cannot connect to the database  because: ' . mysql_error());
 
  $mydb=mysql_select_db("database name");
  
  $sql="SELECT  OrderID, Customer, Address, City, State, ZipCode, Telephone, ServiceCategory, DateCall, WStatus FROM C WHERE OrderID LIKE '%" . $search .  "%' OR Customer LIKE '%" . $search ."%' OR Address LIKE '%" . $search ."%' OR City LIKE '%" . $search ."%' OR State LIKE '%" . $search ."%' OR ZipCode LIKE '%" . $search ."%' OR Telephone LIKE '%" . $search ."%' OR ServiceCategory LIKE '%" . $search ."%' OR DateCall LIKE '%" . $search ."%' OR WStatus LIKE '%" . $search ."%'";
  
 $result=mysql_query($sql);
{
if (mysql_num_rows($result)>1) {

echo "<table border='1'>  
<tr>
<th>Order ID</th>
<th>Customer</th>
<th>Address</th>
<th>City</th>
<th>State</th>
<th>Zip Code</th>
<th>Telephone</th>
<th>Service Category</th>
<th>Date of Call</th>
<th>Order Status</th>
</tr>";  
}
  while($row=mysql_fetch_array($result)){
       echo "<tr>";
  echo "<td><a href='http://websitename.com/admin/workorder/link.php?OrderID=" . $row['OrderID'] . "'>" . $row['OrderID'] . "</a></td>";
  echo "<td><a href='http://websitename.com/admin/workorder/link.php?OrderID=" . $row['OrderID'] . "'>" . $row['Customer'] . "</a></td>";
  echo "<td><a href='http://websitename.com/admin/workorder/link.php?OrderID=" . $row['OrderID'] . "'>" . $row['Address'] . "</a></td>";
  echo "<td><a href='http://websitename.com/admin/workorder/link.php?OrderID=" . $row['OrderID'] . "'>" . $row['City'] . "</a></td>"; 
  echo "<td><a href='http://websitename.com/admin/workorder/link.php?OrderID=" . $row['OrderID'] . "'>" . $row['State'] . "</a></td>";
  echo "<td><a href='http://websitename.com/admin/workorder/link.php?OrderID=" . $row['OrderID'] . "'>" . $row['ZipCode'] . "</a></td>";
  echo "<td><a href='http://websitename.com/admin/workorder/link.php?OrderID=" . $row['OrderID'] . "'>" . $row['Telephone'] . "</a></td>";
  echo "<td><a href='http://websitename.com/admin/workorder/link.php?OrderID=" . $row['OrderID'] . "'>" . $row['ServiceCategory'] . "</a></td>";
  echo "<td><a href='http://websitename.com/admin/workorder/link.php?OrderID=" . $row['OrderID'] . "'>" . $row['DateCall'] . "</a></td>";
  echo "<td><a href='http://websitename.com/admin/workorder/link.php?OrderID=" . $row['OrderID'] . "'>" . $row['WStatus'] . "</a></td>";  
  echo "</tr>";  
    
}
}
echo "</table>";
if(mysql_num_rows($result)==0){
  echo "<p><a href='aworkorder.html'> No record Found. Add Work Order</a>"; }
  }
  else{
  echo  "<p>Please enter a search query</p>";
  }
  }
  }
mysql_close($db);
?>

I think it's something simple but I figured I'd just ask for some help rather than continue bashing my head against a wall...Thanks

what problem you have??, i can't understand what you want ??
which kind of editor??

The table is not printing. The result is just displayed as one long hyperlink.

An editor that looks for minor problems like if you have a { but no }.

what problem you have??, i can't understand what you want ??
which kind of editor??

Try Now >>

<?php
  if(isset($_POST['submit'])){
  if(isset($_GET['go'])){
  if(preg_match("/^[  a-zA-Z0-9]+/", $_POST['search'])){
  $search=$_POST['search'];
  
  $db=mysql_connect  ("connection info") or die ('I cannot connect to the database  because: ' . mysql_error());
 
  $mydb=mysql_select_db("database name");
  
  $sql="SELECT  OrderID, Customer, Address, City, State, ZipCode, Telephone, ServiceCategory, DateCall, WStatus FROM C WHERE OrderID LIKE '%" . $search .  "%' OR Customer LIKE '%" . $search ."%' OR Address LIKE '%" . $search ."%' OR City LIKE '%" . $search ."%' OR State LIKE '%" . $search ."%' OR ZipCode LIKE '%" . $search ."%' OR Telephone LIKE '%" . $search ."%' OR ServiceCategory LIKE '%" . $search ."%' OR DateCall LIKE '%" . $search ."%' OR WStatus LIKE '%" . $search ."%'";
  
 $result=mysql_query($sql);
//{
	if (mysql_num_rows($result)>1) {

	echo "<table border='1'>  
	<tr>
	<th>Order ID</th>
	<th>Customer</th>
	<th>Address</th>
	<th>City</th>
	<th>State</th>
	<th>Zip Code</th>
	<th>Telephone</th>
	<th>Service Category</th>
	<th>Date of Call</th>
	<th>Order Status</th>
	</tr>";  
	//}
		  while($row=mysql_fetch_array($result)){
			   echo "<tr>";
				  echo "<td><a href='http://websitename.com/admin/workorder/link.php?OrderID=" . $row['OrderID'] . "'>" . $row['OrderID'] . "</a></td>";
				  echo "<td><a href='http://websitename.com/admin/workorder/link.php?OrderID=" . $row['OrderID'] . "'>" . $row['Customer'] . "</a></td>";
				  echo "<td><a href='http://websitename.com/admin/workorder/link.php?OrderID=" . $row['OrderID'] . "'>" . $row['Address'] . "</a></td>";
				  echo "<td><a href='http://websitename.com/admin/workorder/link.php?OrderID=" . $row['OrderID'] . "'>" . $row['City'] . "</a></td>"; 
				  echo "<td><a href='http://websitename.com/admin/workorder/link.php?OrderID=" . $row['OrderID'] . "'>" . $row['State'] . "</a></td>";
				  echo "<td><a href='http://websitename.com/admin/workorder/link.php?OrderID=" . $row['OrderID'] . "'>" . $row['ZipCode'] . "</a></td>";
				  echo "<td><a href='http://websitename.com/admin/workorder/link.php?OrderID=" . $row['OrderID'] . "'>" . $row['Telephone'] . "</a></td>";
				  echo "<td><a href='http://websitename.com/admin/workorder/link.php?OrderID=" . $row['OrderID'] . "'>" . $row['ServiceCategory'] . "</a></td>";
				  echo "<td><a href='http://websitename.com/admin/workorder/link.php?OrderID=" . $row['OrderID'] . "'>" . $row['DateCall'] . "</a></td>";
				  echo "<td><a href='http://websitename.com/admin/workorder/link.php?OrderID=" . $row['OrderID'] . "'>" . $row['WStatus'] . "</a></td>";  
				  echo "</tr>";  
			
		}

		echo "</table>";
  }
//}

	if(mysql_num_rows($result)==0){
	  echo "<p><a href='aworkorder.html'> No record Found. Add Work Order</a>"; }
	  }
	  else{
	  echo  "<p>Please enter a search query</p>";
	  }
  }
  }
mysql_close($db);
?>

if your problem get solved then let me now?? and Use Edit Plus editor,,
and do some necessary settings like match braces etc..

that didn't work but I'll continue checking. I know it's something simple

if your problem get solved then let me now?? and Use Edit Plus editor,,
and do some necessary settings like match braces etc..

try this and i think you need a best editor, cause you mismatched the parentheses braces

<?php
  if(isset($_POST['submit'])){
  if(isset($_GET['go'])){
  if(preg_match("/^[  a-zA-Z0-9]+/", $_POST['search'])){
  $search=$_POST['search'];
  
  $db=mysql_connect  ("connection info") or die ('I cannot connect to the database  because: ' . mysql_error());
 
  $mydb=mysql_select_db("database name");
  
  $sql="SELECT  OrderID, Customer, Address, City, State, ZipCode, Telephone, ServiceCategory, DateCall, WStatus FROM C WHERE OrderID LIKE '%" . $search .  "%' OR Customer LIKE '%" . $search ."%' OR Address LIKE '%" . $search ."%' OR City LIKE '%" . $search ."%' OR State LIKE '%" . $search ."%' OR ZipCode LIKE '%" . $search ."%' OR Telephone LIKE '%" . $search ."%' OR ServiceCategory LIKE '%" . $search ."%' OR DateCall LIKE '%" . $search ."%' OR WStatus LIKE '%" . $search ."%'";
  
 $result=mysql_query($sql);
//{
	if (mysql_num_rows($result)>1) {

	echo "<table border='1'>  
	<tr>
	<th>Order ID</th>
	<th>Customer</th>
	<th>Address</th>
	<th>City</th>
	<th>State</th>
	<th>Zip Code</th>
	<th>Telephone</th>
	<th>Service Category</th>
	<th>Date of Call</th>
	<th>Order Status</th>
	</tr>";  
	//}
		  while($row=mysql_fetch_array($result)){
			   echo "<tr>";
				  echo "<td><a href='http://websitename.com/admin/workorder/link.php?OrderID=" . $row['OrderID'] . "'>" . $row['OrderID'] . "</a></td>";
				  echo "<td><a href='http://websitename.com/admin/workorder/link.php?OrderID=" . $row['OrderID'] . "'>" . $row['Customer'] . "</a></td>";
				  echo "<td><a href='http://websitename.com/admin/workorder/link.php?OrderID=" . $row['OrderID'] . "'>" . $row['Address'] . "</a></td>";
				  echo "<td><a href='http://websitename.com/admin/workorder/link.php?OrderID=" . $row['OrderID'] . "'>" . $row['City'] . "</a></td>"; 
				  echo "<td><a href='http://websitename.com/admin/workorder/link.php?OrderID=" . $row['OrderID'] . "'>" . $row['State'] . "</a></td>";
				  echo "<td><a href='http://websitename.com/admin/workorder/link.php?OrderID=" . $row['OrderID'] . "'>" . $row['ZipCode'] . "</a></td>";
				  echo "<td><a href='http://websitename.com/admin/workorder/link.php?OrderID=" . $row['OrderID'] . "'>" . $row['Telephone'] . "</a></td>";
				  echo "<td><a href='http://websitename.com/admin/workorder/link.php?OrderID=" . $row['OrderID'] . "'>" . $row['ServiceCategory'] . "</a></td>";
				  echo "<td><a href='http://websitename.com/admin/workorder/link.php?OrderID=" . $row['OrderID'] . "'>" . $row['DateCall'] . "</a></td>";
				  echo "<td><a href='http://websitename.com/admin/workorder/link.php?OrderID=" . $row['OrderID'] . "'>" . $row['WStatus'] . "</a></td>";  
				  echo "</tr>";  
			
		}

		echo "</table>";
  }
else
  {
	echo "<p><a href='aworkorder.html'> No record Found. Add Work Order</a>";
  }
//}
/*
	if(mysql_num_rows($result)==0){
	  echo "<p><a href='aworkorder.html'> No record Found. Add Work Order</a>"; }
	  //}
	  else{
	  echo  "<p>Please enter a search query</p>";
	  }
	  */
  }
  }
mysql_close($db);
?>

and let me know quickly if you not found solved>> :)

mark solved if you find.

Thanks for your help but the solution did not have to do with brackets. The problem was with the if statement at this:

if (mysql_num_rows($result)>1)

it should be

if (mysql_num_rows($result)>0)

Do I get points for solving my own thread? LOL. But seriously thanks for your help!

mark solved if you find.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.