Jump to content

how to add edit and delete options beside every result ?


keloa

Recommended Posts

Hi 

I'm working in a project and I just finished the pagination system (in every page 2 results) but my problem is that I want to add some options beside every result.For example I have to resut which are (john,katy)I want them to be like this :

John (Edit) (Delete)

Katy (Edit) (Delete)

 

This is my code :

<?php
include("wasata/inc/config.php");
mysql_query('SET NAMES "UTF-8"');
if(!isset($_GET['page'])){
	$page = 1;
}else{
	$page = (int) $_GET['page'];
	$records_at_page = 2;
	$q = mysql_query('SELECT * FROM serv');
	$records_count = @mysql_num_rows($q);
	@mysql_free_result($q);
	$page_count = (int) ceil($records_count / $records_at_page);
	if(($page > $page_count) || ($page <= 0)){
		mysql_close($con);
		die('No More Pages');
	}
	$start = ($page - 1) * $records_at_page;
	$end   = $records_at_page;

	if($records_at_page != 0){
		$q = mysql_query("SELECT * FROM serv ORDER BY id ASC LIMIT $start,$end");
		while($o = mysql_fetch_object($q)){
			echo $o->title .'<br />';
		}
	}
	echo '<br />';
	for($i = 1; $i<= $page_count; $i++){
		if($page == $i){
			echo $page;
		}else{
			echo '<a href="m.php?page=' .$i . '">' .$i . '</a>';
			if($i != $page_count){
				echo ' - ';
			}
		}

	}
}
mysql_close($con);
?> 

So can any one Help please.

 

Link to comment
Share on other sites

 

From your question i understand this: 

while($o = mysql_fetch_object($q)){
			echo $o->title.'(edit)(delete)<br />';
		}

Will, I need this (edit)and (delete) to be buttons and when I click on edit I'm going to be able to edit some data from the database.and if I clicked on delete it will delete this row.

Link to comment
Share on other sites

the point of programming help isn't to find or to write code for you. other than posting your current code and a statement of what you want, what have you tried? (hint: this is a common assignment and there are countless examples posted on the Internet that you could find and examine to see how others have done this.)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.