Jump to content

[SOLVED] Delete.


Freig

Recommended Posts

Hi there.

 

Im trying to make a delete link/funktion in my links section. I have a little PHP experience but not much.

 

my code looks like this:

 

<table width="100%" border="0" cellpadding="0" cellspacing="0">
						<b>
							<td>
								Linknavn:
							</td>
							<td>
								URL:
							</td>
						</b>
						<?php

						mysql_connect("x", "xx", "xxx");
						mysql_select_db("yyy");

						$query = mysql_query("select * from links ORDER BY  linknavn  ASC");

						while ($row = mysql_fetch_array($query))

						{
						echo "<tr align='left'>";
						echo '<td>'
						<? 
								mysql_connect("x", "xx", "xxx"); 
								mysql_select_db("ks1more"); 

								if(!isset($cmd)) 
								{
							    	$result = mysql_query("select * from links order by id"); 
   
   									while($r=mysql_fetch_array($result)) 
   									{ 
   								             $id=$r["id"];
     
 								echo "<a href='delete.php?cmd=delete&id=$id'>Delete</a>";
     								            echo "<br>";
    								             }
								}
						?>
						<?
								if($_GET["cmd"]=="delete")
								{
									$delid = (int) $_GET["id"];
								    $sql = "DELETE FROM link WHERE id=$delid";
								    $result = mysql_query($sql);
								    echo "Row deleted!";
								}
						?>
						echo '</td>'
					             echo "<td>". $row["linknavn"] ."</td>";
	    	  		                          echo "<td>". $row["links"] ."</td>";
	    	                                                    echo "</tr>";
		                                                        }
			          	
			          	                         mysql_close(MYSQL *mysql);
			          	
						?>

					      </table>

 

It returns a blank code, I cannot find the solution, can you help me please.

Link to comment
https://forums.phpfreaks.com/topic/61998-solved-delete/
Share on other sites

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.