hello
i made page with a form to insert data to the mysql database (with copy paste as i started learning yesterday) it works i put the code in a div

i want to add a delete link for the records listed but it doesnt work in echo.

how can i do it ?

<html>
<head>
<!-- TinyMCE -->
<script type="text/javascript" src="tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript">
    tinyMCE.init({
        mode : "textareas",
        theme : "simple"
    });
</script>
<!-- /TinyMCE -->
<link rel="stylesheet" type="text/css" href="qwe.css" />
</head>

<body>
<div class="qwe">
<form action="verigiris.php" method="post">


<textarea cols="65" rows="5" name="yazi"></textarea>

<input type="submit" />
</form>
</div>

<?php

$con = mysql_connect("localhost","user","123");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("b33_2821424_phpsite", $con);

$result = mysql_query("SELECT * FROM gunluk");



while($row = mysql_fetch_array($result))


  {
 echo "<div class='qwe'>";
  echo $row['yazi'];
   echo "</div>";
  }



mysql_close($con);
?>






</body>
</html>

Well first of all, welcome to daniweb. And on future posts can you please use code tags (I know its your first time so I undertand). As for the problem, you will need a second php file just for deleting the mysql entries. First your while loop would look something like this:

while($row = mysql_fetch_array($result))


{
echo "<div class='qwe'>";
echo $row['yazi'];
echo '<br>'
echo '<a href="delete.php?q='.$row['id'].'">Delete</a>'
//$row['id'] is your id field that makes each row unique
//and id may need to be change to the real name
echo "</div>";
}

Then delete.php

<?
mysql_query('DELETE * FROM `table` WHERE `id` = "'.mysql_real_escape_string($_GET['delete']).'"') or die(mysql_error());
//now redirect back
header('Location: http://www.yoursite.com/folder/index.php');
?>

But in that second code box, remember the replace `table` and `id` with the table name and the real column name.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.