# If non-member, make column invisble

**URL:** https://forum.kirupa.com/t/if-non-member-make-column-invisble/157050
**Category:** programming
**Created:** [July 29, 2005, 4:53pm UTC](https://forum.kirupa.com/t/if-non-member-make-column-invisble/157050 "2005-07-29T16:53:54Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Nick](https://avatars.discourse-cdn.com/v4/letter/n/f9ae1b/32.png) [@Nick](https://forum.kirupa.com/u/Nick)
#### Post date: [July 29, 2005, 4:53pm UTC](https://forum.kirupa.com/t/if-non-member-make-column-invisble/157050/1 "2005-07-29T16:53:54Z")

</div>

Hello,

I need some help with my script. I’m trying to make a database for products to be displayed. Thus far, it works but I wan’t it to not allow non-members to see the price column - only members should be able to see it! I have successfully made it so a non-member cannot see the page intirely but how can I make it so he can only not see the price? Many thanks. Here’s my code (srry for the mess):

//If showprice is 0, I want $price to be “” or its column to disappear!  
\<?  
session\_start();  
if (!isset($\_SESSION[‘user\_is\_logged\_in’]) || $\_SESSION[‘user\_is\_logged\_in’] !== true) {  
$showprice = 0;  
} ?\>  
\<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”  
“[http://www.w3.org/TR/html4/loose.dtd](http://www.w3.org/TR/html4/loose.dtd)”\>  
\<html\>  
\<head\>  
\<title\>Untitled Document\</title\>  
\<meta http-equiv=“Content-Type” content=“text/html; charset=iso-8859-1”\>  
\</head\>

\<body\>

\<?

//Logging into the database

$dbhost = “localhost”; // Database Server  
$dbname = “test”; // Database Name  
$dbuname = “\*\*\*”; // Database User  
$dbpass = “\*\*\*”; // Database Pass

//Selecting the database  
function dbconnect()  
{  
global $dbhost, $dbuname, $dbpass, $dbname;  
mysql\_connect($dbhost, $dbuname, $dbpass);  
@mysql\_select\_db($dbname) or die (“Unable to select database !”);  
}

function query\_db($query)  
{  
dbconnect();  
return @mysql\_query($query);  
}

//The rest

if ($page == del) { //Don’t mind this, I’ll disable deleting stuff later

$mysql\_link = mysql\_connect($dbhost, $dbuname, $dbpass);  
$sql = “DELETE FROM products WHERE id = ‘$del’”;  
mysql\_db\_query($dbname, $sql, $mysql\_link);  
echo “\<font color=$fontcolor size=2 face=verdana\>\<b\>\<center\>\<i\>\<p\>Product DELETED\</i\>\</center\>\</b\>\</font\>”;  
}  
else {

dbconnect();  
$data = query\_db(“SELECT \* FROM products”);  
if (!$data) { echo( mysql\_error()); }  
else {  
ECHO"\<P\>\<center\>\<table bgcolor=RED cellspacing=2 cellpading=2\>\<tr\>\<th bgcolor=white\>ID\</th\>\<th bgcolor=white\>NAME\</th\>\<th bgcolor=white\>PICTURE\</th\>\<th bgcolor=white\>PRICE\</th\>\<th bgcolor=white\>CODE\</th\>\<th bgcolor=white\>DESCRIPTION\</th\>\<th bgcolor=white\>\</th\>\<th bgcolor=white\>\</th\>\</tr\>";

```
	while ($row = mysql_fetch_array($data)) {
		$id = $row["id"];
		$name = $row["name"];
		$image = $row["image"];
		$price = $row["price"];
		$code = $row["code"];
		$description = $row["description"];
		//If user is not logged on

```

echo "\<tr\>\<th bgcolor=white\>$id\</th\>\<th bgcolor=white\>$name\</th\>\<th bgcolor=white\>\<img src=$image\>\</th\>

\<th bgcolor=white\>$price\</th\>

\<th bgcolor=white\>$code\</th\>\<th bgcolor=white\>$description\</th\>  
\<th bgcolor=white\>EDIT\</th\>\<th bgcolor=yellow\>\<a href=inserturlhere\>DELETE\</a\>\</th\>\</tr\>";  
}  
echo"\</table\>\</center\>";  
}}

?\>

\</body\>  
\</html\>
