Thanx for your reply
$query = "SELECT tax_id, c_registration_no, start_date, tax_reference_number FROM tax ".$conditional." ORDER BY $Order $InOrder";
it comes out with this error message mate
Parse error: syntax error, unexpected T_VARIABLE in C:\apachefriends\xampp\htdocs\searchtaxref2.php on line 184
which I don't understand at all
I really hope you can help me with this
this is the whole search code I have created so far
<form name="search" action=<?php Print $_SERVER["PHP_SELF"]; ?> method="post">
<br>
<hr width=100%>
<?php
$Order = (isset($_POST['Order']))?$_POST['Order']:"tax_id";
$InOrder = (isset($_POST['InOrder']))?$_POST['InOrder']:"";
$taxref = (isset($_POST['taxref']))?$_POST['taxref']:"";
?>
<div align="center" class="style14"><strong>You have to choose One means of search either:
<br>
</strong></div>
<table align=center>
<th align=center><span class="style7">Search For Tax Reference Number: </span>
<td><input type ="text" name="taxref" value ="<?print $taxref;?>"size="40">
</table>
<br>
<table align=center>
<td> <span class="style13">Make Search Found Ascending Or Descending:</span>
<select name="InOrder">
<option value="ASC"<?if ($InOrder == "ASC"){print ' SELECTED ';}?>>Ascending</option>
<option value="DESC"<?if ($InOrder == "DESC"){print ' SELECTED ';}?>>Descending</option>
</select>
</table>
<br>
<table align=center>
<th align=center>
<td><input type="submit" name="submit" value="Search" />
</table>
<br>
<hr width=100%>
<?
//May not be needed depending on the connection.
$conn = mysql_connect("localhost","root","") or die("Could Not Connect To The Database");
mysql_select_db("aziz",$conn) or die("Could Not Select The Database");
//build up query using each conditional - else statement refers to search field.
$conditional = "";
if ($taxref ==""){
$conditional=$conditional."tax_reference_number = '".$taxref."' OR ";
}
$conditional="WHERE ".substr($conditional,0,strlen($conditional)-4);
$query = "SELECT tax_id, c_registration_no, start_date, tax_reference_number FROM tax ORDER BY $Order $InOrder";
$search = mysql_query($query,$conn);
$NumRows=mysql_num_rows($search);
?>
<center>
<b></strong><?print "There are $NumRows found items relate to your search ";?></b>
<span class="style3"><span class="style3 style5"></span></span>
</center>
<br>
<table border="0" cellpadding="0" cellspacing="0" align="center">
<tr height="20">
<td bgcolor="#93B0B4" width="145"><span class="style4 style14"><strong>Tax ID </strong></span></td>
<td bgcolor="#93B0B4" width="145"><span class="style4 style14"><strong>Company Registration Number</strong></span></td>
<td bgcolor="#93B0B4" width="145"><span class="style14 style4"><strong>Tax Start Date (YYYY-MM-DD)</strong></span></td>
<td bgcolor="#93B0B4" width="145"><span class="style4 style14"><strong>Tax Reference Number</strong></span></td>
<td bgcolor="#93B0B4" width="125"><span class="style14 style4"><strong>View Client</strong></span></td>
</tr>
<tr>
<td>
<?php
if($NumRows>0){
//get the first row and begin the table.
$row = mysql_fetch_assoc ($search);
//reset the result set back to the first row and display the data set.
mysql_data_seek ($search, 0);
while ($row = mysql_fetch_row ($search)) {
echo "<tr valign=top>";
echo "<td bgcolor=#93B0B4 colspan=6></td>";
echo "</tr>";
print "<TR>\n";
print "<TD>$row[0]</TD>";
print "<TD>$row[1]</TD>";
print "<TD>$row[2]</TD>";
print "<TD>$row[3]</TD>";
if($row[3]=="taxrefno"){
?>
</td>
</tr>
</table>
<?php
print $row[0];
?>
<?php
print "</TR>";
}
else{
?>
</form>
</blockquote>
<td><a href ="viewtax2.php?id=
<?php
print $row[0];
?>
">View</a></td>
<?php
print "</tr>";
}
}
print "</table>";
}
?>
but I think the main problem lies between this part of the code
<?php
$Order = (isset($_POST['Order']))?$_POST['Order']:"tax_id";
$InOrder = (isset($_POST['InOrder']))?$_POST['InOrder']:"";
$taxref = (isset($_POST['taxref']))?$_POST['taxref']:"";
?>
<div align="center" class="style14"><strong>You have to choose One means of search either:
<br>
</strong></div>
<table align=center>
<th align=center><span class="style7">Search For Tax Reference Number: </span>
<td><input type ="text" name="taxref" value ="<?print $taxref;?>"size="40">
</table>
<br>
<table align=center>
<td> <span class="style13">Make Search Found Ascending Or Descending:</span>
<select name="InOrder">
<option value="ASC"<?if ($InOrder == "ASC"){print ' SELECTED ';}?>>Ascending</option>
<option value="DESC"<?if ($InOrder == "DESC"){print ' SELECTED ';}?>>Descending</option>
</select>
</table>
<br>
<table align=center>
<th align=center>
<td><input type="submit" name="submit" value="Search" />
</table>
<br>
<hr width=100%>
<?
//May not be needed depending on the connection.
$conn = mysql_connect("localhost","root","") or die("Could Not Connect To The Database");
mysql_select_db("aziz",$conn) or die("Could Not Select The Database");
//build up query using each conditional - else statement refers to search field.
$conditional = "";
if ($taxref ==""){
$conditional=$conditional."tax_reference_number = '".$taxref."' OR ";
}
$conditional="WHERE ".substr($conditional,0,strlen($conditional)-4);
$query = "SELECT tax_id, c_registration_no, start_date, tax_reference_number FROM tax ORDER BY $Order $InOrder";
$search = mysql_query($query,$conn);
$NumRows=mysql_num_rows($search);
?>
basically it is not responding to the "search" button at its just printing out all the infor mation in the "tax" table regardless what is typed in the search field hope someone can help me with this coz it s really frustrating me
basically I have a search field and search button and if a user types into the search field and the search button is clicked if it matches the name it will show the realted information on the table but if no matches it will just say to items found but at the moment it shows all the information from the "tax" table with out the user entering anything and if the uer enters the reference number into the field and it matches the reference number in the database, instead of it just printing the reference number corresponding to the one that is type in it will not update the table it will still show all the data in the tax table instead. This goes the same for when the reference number doesn't match, instead of it saying no items found it continues to show all the data from the tax table. Basically the reference number typed into is not responding the the submit button I don't know why I rellly hope you or anybody can help I have tried everything and I just can seem to find away to solve this problem
Thank you for your time
Hopefully you can help me to sort this problem out thank you again
Takecare