Jump to content

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/65934-solved-problem-with-if-statement/
Share on other sites

It is Category. I am using the output for other database fields. All outputs work fine, its just the Category field.

 

If I type:

echo ("</td>"."<td>".$row->Title."</td>"."<td>".$row->Category."</td>");

and the Category for that "id" number is equal to 3, then 3 would be output as plain text. However, I want to do an array of some sort or an if statement.

stdClass Object
(
    [id] => 1
    [Meta_Description] => meta describtion about cbfi
    [Meta_Keywords] => Keywords,lol,haha,rolled,pwned, haha
    [Title] => CBFI Title
    [subTitle] => Subtitle
    [Content] => Lorem
    [Theme_Image] => 0
    [Category] => 2
)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.