RE:Using PHP to query a database. I cannot work syntax.
Posted: Sun May 24, 2009 5:21 am
Hi,
I'm having a bit of trouble with an aspect of my website. My site is a photography website. You can login to access member content. This works ok but I want a second level of login where only clients I have put on the database can access proofs of their photos. There is a permission column in my database. If I have registered them they will have 'valid' in the permission column if they have just registered themselves on the site they will have 'null' in the permission column. I want to determine whether someone is logged in and check the database to see if they have 'valid', if they do the link will appear. I have been using PHP for about 2 weeks so excuse any stupidity. Below is my attempt.
I would really appreciate any help.
Chris

I'm having a bit of trouble with an aspect of my website. My site is a photography website. You can login to access member content. This works ok but I want a second level of login where only clients I have put on the database can access proofs of their photos. There is a permission column in my database. If I have registered them they will have 'valid' in the permission column if they have just registered themselves on the site they will have 'null' in the permission column. I want to determine whether someone is logged in and check the database to see if they have 'valid', if they do the link will appear. I have been using PHP for about 2 weeks so excuse any stupidity. Below is my attempt.
Code: Select all
<?php
session_start();
include("dbconnect.php");
$query = "SELECT * FROM registerid where permission = '$valid'";
$result=mysql_query($query);
$row=mysql_fetch_row($result);
$numrows=mysql_num_rows($result);
if ($numrows!=0){
echo ("<a href=\"#"><img alt=\"Click here to view proofs\" src=\"images/proofs.gif\" id=\"a1\" border=\"0\"/></a>");
}
else{
echo '';
}
?>Chris