Jump to content

delete only displayed data


yanti

Recommended Posts

Do you want it to display all the rows except a specific one on the page load?

 

If you're trying to display all the rows except for a specific one.. you could just put

if($row['title'] == "Whatever title of what you don't want displayed")
{}
else
{
//all the others and the echos
}

in your foreach or while loop, which will print the ones you want and skip the row you don't.

my current code is like this...

<?php
$con = mysql_connect("","","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("manisfm", $con);

$result = mysql_query("SELECT * FROM topik ORDER BY id DESC");

echo "<table border='1'>
<tr>
<th>ID</th>
<th>DATE / TIME</th>
<th>SENDER</th>
<th>TOPIK HANGAT</th>
</tr>";

while($row = mysql_fetch_array($result))
  {
  echo "<tr>";
  echo "<td>" . $row['id'] . "</td>";
  echo "<td>" . $row['datetime'] . "</td>";
  echo "<td>" . $row['sender'] . "</td>";
  echo "<td>" . $row['topik'] . "</td>";
  echo "</tr>";
  }
echo "</table>";

mysql_close($con);
?>

so where should i put it?

<?php
$con = mysql_connect("","","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("manisfm", $con);

$result = mysql_query("SELECT * FROM topik WHERE `valid`='1' ORDER BY id DESC");

echo "<table border='1'>
<tr>
<th>ID</th>
<th>DATE / TIME</th>
<th>SENDER</th>
<th>TOPIK HANGAT</th>
<th>DELETE</th>
</tr>";

while($row = mysql_fetch_array($result))
  {
  echo "<tr>";
  echo "<td>" . $row['id'] . "</td>";
  echo "<td>" . $row['datetime'] . "</td>";
  echo "<td>" . $row['sender'] . "</td>";
  echo "<td>" . $row['topik'] . "</td>";
  echo "<td><a href='delete.php?id=" . $row['id'] . "'>DELETE THIS</a></td>";
  echo "</tr>";
  }
echo "</table>";

mysql_close($con);
?>

 

And in the delete.php write this:

 

<?php
$con = mysql_connect("","","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("manisfm", $con);

mysql_query("UPDATE `topik` SET `valid`='0' WHERE `id`='$_GET[id]'",$con);
?>

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.