Jump to content

delete only displayed data


yanti

Recommended Posts

??? hi guys...just want to ask how am i delete current displayed data without remove it from database.

for an example, i have select all data from database to be display. but i want to remove the row of displayed data without delete in database. so that the data will keep remain. any idea guys... :o

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

ok....maybe my question got confused..... ::)

 

eg. i display all data from database using column. now, i want to add delete column so that user can delete each row of data so that it wont appear in front end. but, the data still remain in database.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

<?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);
?>

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.