Delete SQL entries from php

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
dilby
Forum Newbie
Posts: 6
Joined: Tue Nov 09, 2010 11:08 am

Delete SQL entries from php

Post by dilby »

Hi - I am using some software a guy I know did and I am cutting my teeth for PHP on it, so please excuse possible stupid questions.

i have a list of questions that users have asked. They are shown using the following file 'edit_fq.php' file location in the 'view' directory

Code: Select all

<table class="list">
	<tr>
		<th><?php echo getlocal("fqedit.question") ?></th>
		<th><?php echo getlocal("fqedit.answer") ?></th>
		<th><?php echo getlocal("fqedit.operator") ?></th>
		<th><?php echo getlocal("fqedit.created") ?></th>
		<th><?php echo getlocal("fqedit.updated") ?></th>
		<th></th>
	</tr>
<?php 
	$all_questions = get_featured_questions();

	while ($question = mysql_fetch_assoc($all_questions)):
?>
	
	<tr onclick="edit_question('<?php echo $question['id']?>');">
		<td><?php echo $question['question']?></td>
		<td><?php echo $question['answer']?></td>
		<td><?php echo $question['operator']?></td>
		<td><?php echo $question['created']?></td>
		<td><?php echo $question['updated']?></td>
		<td><a>remove</a></td>
	</tr>
	
<?php endwhile;?>
</table>		

<?php 
I then have a php file called the same in the operator folder:

Code: Select all

<?php 
require_once('../libs/common.php');
require_once('../libs/operator.php');
require_once('../libs/settings.php');

$operator = check_login();
$link = connect();

function get_featured_questions(){

	$getQuestions = mysql_query('SELECT a.id as id,a.question as question, a.answer as answer, a.created as created, a.updated as updated, b.vclogin as operator
	 FROM featured_questions as a, chatoperator as b WHERE a.operator_id=b.operatorid',connect());
	return $getQuestions;
}

prepare_menu($operator);
setup_settings_tabs(3);
start_html_output();
require('../view/edit_fq.php');
?>
What I want to do is add an option to delete entries, where you can see the 'remove' a tag.

My SQL :

All these entries are stored in a 'featured_questions' table with the rows 'id', 'question', 'answer', 'operator_id', 'created', 'updated'.

I realise this info is hard to put in an easy way, but if I can give any other details that would make it easier please let me know. I just really am desperate to know how to add this feature which would be a great learning step for me. Also any suggestions on how to add a notice of what entry has been deleted etc. Thanks!
Post Reply