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

  • SEARCH
  • Home
  • 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 8722819
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:29:42+00:00 2026-06-13T07:29:42+00:00

* strong text *I don’t know if the title was clear or not, but

  • 0

*strong text*I don’t know if the title was clear or not,

but I want a PHP script that tells if a MySQL column has data, and if it does to print a line of text, but if it is NULL, to print something else…

Make sense?

Here is what I have, I know it is completely wrong…

$link = mysql_connect($DBHOST, $DBUSER, $DBPASSWORD);
mysql_select_db($DBNAME); 
if (!$link) {
    die('Could not connect: ' . mysql_error());
}

$result = mysql_query("SELECT * FROM members");

while($row = mysql_fetch_assoc($result))
{
     if($row['VIP'] = '1')
     {
        echo('VIP');
     }
     else
     {
        echo('Non-VIP');
     }
}

EDIT::

Here is the full code:

<?php

$DBTYPE = 'mysql';
$DBHOST = 'host';
$DBUSER = 'username';
$DBPASSWORD = 'password';
$DBNAME = 'database';

$link = mysql_connect($DBHOST, $DBUSER, $DBPASSWORD);
mysql_select_db($DBNAME); 
if (!$link) {
    die('Could not connect: ' . mysql_error());
}
$member_id= '5'; // get value of the member, assumed that you have post the data into id. change if it is different into your code

$result = mysql_query("SELECT * FROM members where id=$member_id");

while($row = mysql_fetch_assoc($result))
{
     if($row['VIP'] == '1')
     {
        echo "<img src='../images/VIP.png' />";
     }
     else
     {
        echo 'Non-VIP';
     }
}
?>
  • 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-13T07:29:43+00:00Added an answer on June 13, 2026 at 7:29 am

    use == to check equality, like this:

    if($row['VIP'] == '1')
    {
      echo('VIP');
    }
    else
    {
     echo('Non-VIP');
    }
    

    EDIT

    Use below code to get your desired result

    $link = mysql_connect($DBHOST, $DBUSER, $DBPASSWORD);
    mysql_select_db($DBNAME); 
    if (!$link) {
        die('Could not connect: ' . mysql_error());
    }
    $member_id=$_POST['id']; // get value of the member, assumed that you have post the data into id. change if it is different into your code
    
    $result = mysql_query("SELECT * FROM members where id=$member_id");
    
    while($row = mysql_fetch_assoc($result))
    {
         if($row['VIP'] == '1')
         {
            echo "<img src='../images/VIP.png' />";
         }
         else
         {
            echo 'Non-VIP';
         }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

strong text I have grids showing to user and want to not allow sorting
I need help on my php, I don't know how to do this but
* strong text *what i want to do is from my breakline content to
I want to do something like this: [Display(Name = Plain text. <span class=\red strong\>Red
My script works very strange, I get all the values, but when I want
I don't know much about JavaScript, but I was able to convert an array
I want to remove the STRONG tags in a text-file. I'm using sed 's/<
I am trying to show text content just with a PHP if condition but
I'm not particular familiar with using jQuery/Javascript so I don't know what the best
I simply want to create something like that: <strong>blah blah</strong> I've been trying 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.