*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';
}
}
?>
use == to check equality, like this:
EDIT
Use below code to get your desired result