My link still won't work ?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
BrettCarr
Forum Newbie
Posts: 22
Joined: Fri Feb 12, 2010 6:45 pm

My link still won't work ?

Post by BrettCarr »

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>';
	}
User avatar
phpcip28
Forum Newbie
Posts: 22
Joined: Sun Aug 29, 2010 1:38 pm
Location: NewYork
Contact:

Re: My link still won't work ?

Post by phpcip28 »

From what I can see, calling the $BB->listing(); method will never return anything.

Maybe you have to make it return the result-set or... something... anything ?
However, I'm also now sure if it should return anything... Maybe it's just populating some property from within the database class it extends. I'm not sure....

But anyway, everything looks ok with the link to the database otherwise.

So... yes... I'm thinking make the listing method return the result-set.
Post Reply