Jump to content

Recommended Posts

I was wondering how to have an option near the mysql row that allows you to delete it?

This is my code here

 

<?php include 'header.php';  // Works.

 

 

?>

<div id="content">

<div id="columnsC"><br/>

<a href="http://www.stixy.com"><img  style="border:0;" src="siteimg/stixy.jpg" alt="stixy"/></a><Br/>

<p>Stixy helps users organize their world on flexible, shareable Web-based bulletin boards called Stixyboards. Unlike most personal productivity or project management software, Stixy doesn't dictate how users should organize their information. Users can create tasks, appointments, files, photos, notes, and bookmarks on their Stixyboards, organized in whatever way makes sense to them. Then they can share Stixyboards with friends, family, and colleagues.</p>

</div>

<div id="columnsD">

<?

/**

* User has already logged in, so display relavent links

*/

echo '<br/>';

if($session->logged_in){

$dbh=mysql_connect ("localhost", "my_user", "my_pass") or die ('I cannot connect to the database because: ' . mysql_error());

mysql_select_db ("my_db");

if(isset($_GET['remove']) && $_GET['remove'] == '1'){

    $sql = "DELETE FROM emailists WHERE stixy=('" . $session->userinfo['email'] . "')";

        if($sqlres = mysql_query($sql)){

            echo '<div id="mes"><ul><li>email address removed</li></ul></div>';

        }else{

            echo mysql_error();

        }

}

//break

if(isset($_GET['insert']) && $_GET['insert'] == 1) {

  $sql = "SELECT stixy FROM emailists WHERE stixy = '{$session->userinfo['email']}'";

  if ($result = mysql_query($sql)) {

    if (!mysql_num_rows($result)) {

      $sql = "INSERT INTO emailists (stixy) VALUES ('" . $session->userinfo['email'] . "')";

      if ($sqlres = mysql_query($sql)){

        echo '<div id="mes"><ul><li>email address added</li></ul></div>';

      } else {

        echo mysql_error();

      }

    } else {

      echo "<div id='mes'><ul><li>email address already exists</li></ul></div>";

    }

  } else {

    echo mysql_error();

  }

}

$query = mysql_query("SELECT stixy FROM emailists WHERE stixy = '{$session->userinfo['email']}'");

 

$result = mysql_num_rows($query);

 

if($result !== 0){

 

echo "<ul><li><a href='stixy.php?remove=1'>Remove yourself from the list</a></li></ul>";

 

} else {

 

echo "<ul><li><a href='stixy.php?insert=1'>Add yourself to the list</a></li></ul>";

 

}

 

echo "<ul>";

  $sql = "SELECT stixy FROM emailists";

  if ($result = mysql_query($sql)) {

    if (mysql_num_rows($result)) {

      while ($row = mysql_fetch_assoc($result)) {

        echo "<li>";  echo $row['stixy'] . "</li>";

       

      }

    }

  }

echo "</ul>";

 

}

else{

?>

<br/>

<p style="border-style: solid;

border-width: 3px;"><b>some text here</b></p>

 

<?

}

?>

 

</div>

 

 

 

<?php include 'sidebar.php'; ?>

<div style="clear: both;"> </div>

</div>

<?php include 'footer.php';  // Works.

 

?>

Link to comment
https://forums.phpfreaks.com/topic/62720-deleting-a-row/
Share on other sites

Please edit your post to add CODE tags around your scripts.

 

And the answer to your question is "yes".  Add a clickable link to each row that passes the record number to a script that executes a DELETE query.

 

Since you already have an open thread with exactly the same question, this thread is being locked.

 

It is against forum rules to wantonly double post. Do not do it!

 

http://www.phpfreaks.com/forums/index.php/topic,152541.0/topicseen.html

Link to comment
https://forums.phpfreaks.com/topic/62720-deleting-a-row/#findComment-312308
Share on other sites

Guest
This topic is now 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.