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