Adding a function

Discussion in 'Web Design & Programming' started by hewstone999, Apr 1, 2009.

  1. hewstone999

    hewstone999 Geek Trainee

    Likes Received:
    0
    Trophy Points:
    0
    I have some code below which outputs a HTML table. The values in each cell come from a database. I want to add a function to the view and delete cell (marked in red) so when everytime a user clicks on it, it will do a SQL command i.e. "Delete * From ".$Dis. How can i do this??

    Code:
    $temp = 1;
    while(!$rs->EOF){
    	$date = $rs->Fields("date1")->value;
    	$time = $rs->Fields("Time1")->value;
    	$Dis = $rs->Fields("table_name")->value;
    	
    
    	if ($temp1 == 1){
    	echo "<tr>";
    		echo "<td><font size='-1'><b>Date</b>";
    		echo "</td>";
    		echo "<td><font size='-1'><b>Time</b>";
    		echo "</td>";	
    		echo "<td><font size='-1'><b>TableName</b>";
    		echo "</td>";
    	echo "</tr>";	
    	}
    	echo "<tr>";
    		echo "<td><font size='-1'>".$date;
    		echo "</td>";
    		echo "<td><font size='-1'>".$time;
    		echo "</td>";	
    		echo "<td><font size='-1'>".$Dis;
    		echo "</td>";
    		echo "<td><font size='-1'>[color=#FF0000]View";[/color]
    		echo "</td>";
    		echo "<td><font size='-1'>[color=#FF0000]Delete";[/color]
    		echo "</td>";
    	echo "</tr>";
    
    $temp = $temp + 1;	
    
    	$rs->MoveNext();
    
     
  2. johnny.dacu

    johnny.dacu Geek Trainee

    Likes Received:
    1
    Trophy Points:
    0
    Well... i think you'll need an other column table with a link like (w w w . s omething.org/delete.php?id=3). Where ?id is a get variable. Then in your script (delete.php) you 'll run a delete query based on this id.
     

Share This Page