Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8031053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T00:57:58+00:00 2026-06-05T00:57:58+00:00

alrighty so what i want to do should be clear by the code below,

  • 0

alrighty so what i want to do should be clear by the code below,
for each row i want to run the code with their, if header is 0, run the first if statement, if it’s 1 run the second.

Problem is, it doesn’t matter what i set it to, it always runs the second if statement thinking header is always 1, even when it isn’t.

to test i added echo (int)$row[‘header’] to the second if statement, and for every row, it echoed 1.

Anyone have any clue on how i can make it do what i want?

Thanks for the help

my php code:

$result = mysql_query("SELECT * FROM LeftMenu_items");
while ($row = mysql_fetch_assoc($result))
{
    if ((int)$row['header'] = 0)
    {
        // echos value is on or not
        echo "<tr><td class='LeftMenu'><a href='" . $row['url'] . "'><b>" . $row['text'] . "</b></a></td></tr>\n";
    }
    else if ((int)$row['header'] = 1)
    {
        // header
        echo "<tr><td class='LeftMenu'>" . (int)$row['header'] . "<b>" . $row['text'] . "</b></td></tr>\n"; 
    }
    else echo "error displaying url";

My table looks like this:

structure:
id  int 
text    text    
url text    
Header  tinyint 

data:
1   Home    http://drudexflash.com/ 1
2   test1   http://text.com/    0
3   ttt blahz   1
4   nullnull    ass 0
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T00:57:59+00:00Added an answer on June 5, 2026 at 12:57 am

    The problem is that you’re assigning a variable rather than comparing.

    if((int)$row['header'] = 0)
    

    should be

    if ((int)$row['header'] == 0)
    

    This isn’t an uncommon bug, so what I sometimes do is switch the order of the value and variable, just to make it clear that I’m comparing vs assigning.

    Example:

    if (0 = (int)$row['header']) // even if you don't catch this as incorrect
                                 // php will throw a 'parse error'
    if (0 == (int)$row['header']) // correct, no error
    

    Some useful documentation: http://www.php.net/manual/en/language.expressions.php
    http://www.php.net/manual/en/language.operators.comparison.php

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Alright, so here's the portion of my code that is giving me a problem.
VB.NET 2010, .NET 4 Hello, I tried running code analysis the first time and
Alright so I just want to confirm something. I am creating a wrapper class
Alright so in Java I want to ask the user for a time in
Alright, so I want the user to be able to enter every character from
Alright, here goes. I'm making a very basic app, and I want the user
Alrighty guys, I got myself in over my head at my internship. Even my
Alrighty so, I've been wanting to learn C for awhile, and now I have
Alright I've been debugging the whole day but can't figure out what the problem
Alright, my friend gave me this code for requesting headers and comparing them to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.