Click to See Complete Forum and Search --> : If not equal in SQL ?


pkng
04-12-2010, 03:00 PM
Hi!

I'm learning PHP and SQL and I wonder if I could get some help. Below I have some code that fetch things from the database. I just wonder how to write the PHP or SQL code if objektnummer and $objekt not is equal?

$query = "SELECT * FROM arkitekturobjekt WHERE objektnummer = '{$objekt}';";

Thanks! :)

skywalker2208
04-12-2010, 03:06 PM
Take a look at
http://dev.mysql.com/doc/refman/4.1/en/comparison-operators.html#operator_not-equal

pkng
04-12-2010, 03:15 PM
OK, thanks for reply, but I find it hard to understand SQL and that manual.

But if i understand it correct, it will return 0 if not equal, or? But how do I get that 0 value from SQL to do something i PHP? I just want to protect someone from entering a number that don't exist i database if someone alter the ?page=12 to a number that don't exist.

Preciate som help, thanks!

skywalker2208
04-12-2010, 03:25 PM
If the query doesn't find a result it will not return anything. If you use mysql_num_rows then that will return 0 because it didn't find anything in the database.

http://php.net/manual/en/function.mysql-num-rows.php

pkng
04-12-2010, 03:36 PM
OK, I'm going to try that. Thanks!