View Full Version : Problem with IF STATEMENT

08-21-2007, 10:03 AM
I am trying to access a database table field called "Category" from a database named 1.

The output of everything else works great, however, I am trying to get an if statement working on the data that is output.

Category has a numeric value of 1-3.

if ($row->Category == '1')
echo ("Products");
else if ($row->Catgeory == '2')
echo ("World");
else if ($row->Catgeory == '3')
echo ("lol");

Can someone tell me what I am doing wrong?
If Category field value = 1, then output Products, if the category field in the database has a value of 2, then output world, etc etc.

08-21-2007, 10:22 AM
There is nothing wrong in if-else statement.
Are you sure about the value of $row->Catgeory.
Try to echo its value before this block and check if it's correctly assigned through your query.

08-21-2007, 10:25 AM
The Category statement is working fine.
If Category contains a numberic value of 3, and I type:

echo (".$row->Category.");

Then 3 will be output.
Can you revise the IF statement and make sure it will work with database query calls such as the $row->Category.

I tried different syntax and possibilities. Sometimes, I get text output of the words, but its not the correct listing.

08-21-2007, 10:37 AM
I was able to solve it. Much Thnaks!