My link still won't work ?
Posted: Sun Aug 29, 2010 10:57 pm
Hi guys, Im trying to get a link to echo out with my data from the sales_peepl table in the sales database that will use the delete() function It is In the same Class as the output() function that is used to return the data.
Now, I can see in mozilla that it is picking up the correct salesid but it doesn't seem to run the function delete() I know it is in the link but im still stuck, what am i doing wrong???
The class I'm Using I've called User it's small so here is the whole thing including the link I'm trying to use In the output() function
Now i know I've posted this code before but I'm really stuck
Code: Select all
<?
session_start();
/**
* This will handle the Users Records
* and handle the login process assigning
* the user varables to the $SESSION
*
*/
class User extends Database
{
/**
* List all the users
* note to self
* add a "where" to the query refering to the id
*
* @param unknown_type $id
*/
public function listing( $id = null )
{
$this->query( "select * from sales_peepl" );
}
/**
* Deletes the user based on the salesid
*
* @param unknown_type $id
*/
public function delete( $id )
{
$this->query( "DELETE FROM sales_peepl WHERE salesid = '{$id}';" );
}
/**
* Outputs the listing
*This is the trouble here, picks up the id but doesn't run the function above
* @return unknown
*/
public function output()
{
return $this->name . '-' . $this->user_name . '<a href="?action=delete&id=' . $this->salesid . '">Delete User</a>';
}
/**
* Checks to see whether the user can be loged in
*
* @param string_type $user_name
* @param string_type $pass_word
* @return $_SESSION[]
*/
public function login($user_name, $pass_word)
{
$this->query( "select * from sales_peepl WHERE user_name = '{$user_name}' AND pass_word = '{$pass_word}';",true );
if($this->next())
{
$_SESSION['user_name'] = $user_name;
$_SESSION['pass_word'] = $pass_word;
$_SESSION['salesid'] = $this->_row->salesid;
$_SESSION['access'] = $this->_row->access;
$_SESSION['name'] = $this->_row->name;
return TRUE;
}
return FALSE;
}
/**
* Logs User Out
*
*/
public function logout()
{
session_destroy();
}
}
?>
This is the output page..
Code: Select all
<?php
include_once($_SERVER['DOCUMENT_ROOT'].'/pete_phone/includes/global.php');
$BB = new User();
$BB->connect(HOST, USERNAME, PASSWORD, DATABASE);
$BB->listing();
?>
<html>
<head></head>
<body>
<?php
while( $BB->next() )
{
echo $BB->output() . " , " ;
}
?>
</body>
</html>
these are the things I've tried
Code: Select all
public function output()
{
return $this->name . '-' . $this->user_name . '<a href="?action=$this->delete&id=' . $this->salesid . '">Delete User</a>';
}
public function output()
{
return $this->name . '-' . $this->user_name . '<a href="?action=$this->delete()&id=' . $this->salesid . '">Delete User</a>';
}
public function output()
{
return $this->name . '-' . $this->user_name . '<a href="?action=$this->delete&id=' . $this->salesid . '">Delete User</a>';
}
public function output()
{
return $this->name . '-' . $this->user_name . '<a href="?action=delete()&id=' . $this->salesid . '">Delete User</a>';
}