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