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.

 

your question isn't specific enough.  We can't answer accurately without more information of what exactly you would like to do and how you would like it to be done.

 

What I will say though is: Stop suppressing your database interactions and stop using SELECT *

 

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.

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.)

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.