Hi guys,
I have added a column in a database, I know how to read the information from the database but I don't know how to check with the column name called "public" whether if the cell has text called enabled or disabled, then add the href link in enabled or disabled text in my php. I need it to allow the clients to control on their own account.
Code:
<?php
session_start();
define('DB_HOST', 'localhost');
define('DB_USER', 'myusername');
define('DB_PASSWORD', 'mypass');
define('DB_DATABASE', 'mydbtable');
$errmsg_arr = array();
$errflag = false;
$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if(!$link) {
die('Failed to connect to server: ' . mysql_error());
}
$db = mysql_select_db(DB_DATABASE);
if(!$db) {
die("Unable to select database");
}
function clean($var){
return mysql_real_escape_string(strip_tags($var));
}
$username = clean($_GET['user']);
$password = clean($_GET['pass']);
if($username == '') {
$errmsg_arr[] = 'username ID missing';
$errflag = true;
}
if($password == '') {
$errmsg_arr[] = 'PASSWORD ID missing';
$errflag = true;
}
if($errflag) {
$_SESSION['ERRMSG_ARR'] = $errmsg_arr;
echo implode('<br />',$errmsg_arr);
}
else {
$qry="SELECT * FROM members WHERE username='$username' AND passwd='$password'";
$result=mysql_query($qry) or die('Error:<br />' . $qry . '<br />' . mysql_error());
if(mysql_num_rows($result) > 0) {
$qrytable1="SELECT images, id, public FROM members WHERE username='$username'";
$result1=mysql_query($qrytable1) or die('Error:<br />' . $qry . '<br />' . mysql_error());
while ($row = mysql_fetch_array($result1)) {
echo '<p id="images"> <a href="images.php?id='.$row['id'].'">Images</a></td> | <a href="http://' . $row["links"] . '">Link</a> </td> | <a href="delete.php?id='.$row['id'].'">Delete</a> </td> | Enabled | Disabled';
}
}
}
?>
What I am trying to achieve is to check the column name called "public" whether if it has text that stored in the database (it could be enabled or disabled) then add the hyperlink in that text of enabled or disabled in the php page so it would allow the user to click one of the link to allow the hyperlink to switch over from enabled to disabled.
E.G: A user is going to click the enabled text with the hyperlink to change the text in the database from enabled to disabled and remove the hyperlink in the php page from enabled to add the hyperlink in the disabled text.
Do anyone know how to do this?
Any advice would be much appreciated.
Thanks in advance.