k4pil Posted March 1, 2006 Share Posted March 1, 2006 Hi there. This should be a quickie...I am inserting data into my database as below;[code]$query = "INSERT INTO product VALUES ('','$prodName','$prodDesc','$supplier','$costPound', '$costPence')"; mysql_query($query); [/code]All values are passed from a form and its all working fine.I then want to query the databse and output products searched for by the user. e.g.[code]$query = "SELECT * FROM product WHERE productID = '$ID' OR prodName = '$prodName' OR prodDesc = '$prodDesc' OR supplier = '$supplier' OR costPound = '$costPound' OR costPence = '$costPence'";$result = mysql_query($query); $num = mysql_numrows($result);[/code]The problem is when the user specifies he/she wants the output contain the row he/she wants but also all other rows that contain the value 0. for example if a product cost £10.00 this is output because in the costPence column the value exists as 0.How can i avoid this? Is there a method or some logic that i need??Thanks in advance as always ppl! Quote Link to comment Share on other sites More sharing options...
running_out_of_imagination Posted March 1, 2006 Share Posted March 1, 2006 If you want the products that cost £10,00 you have to use:[code]costPound = '$costPound' AND costPence = '$costPence'";[/code]Maybe merge both fileds as no one will look up for something that costs £x,65 beeing x any value Quote Link to comment Share on other sites More sharing options...
k4pil Posted March 1, 2006 Author Share Posted March 1, 2006 The cost thing was an example...i was illustrating what the problem i a, having is.For example, when i search for a customer$query = "SELECT * FROM customer WHERE name = '$name'";I get output everything where name = '$name' as well as every row which does not have an entry for name in the customer table.Any help any1??? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.