/    Sign up×
Community /Pin to ProfileBookmark

Survey Help

Hi,

I have a survey (Ideas) page that submits into a MySQL Table. I also have a results page

That loks like this:

[CODE]<?php
$con = mysql_connect(“localhost”,”username”,”password”);
if (!$con)
{
die(‘Could not connect: ‘ . mysql_error());
}

mysql_select_db(“database”, $con);

$result = mysql_query(“SELECT * FROM ideas”);

echo “<table border=’1′ align=’center’ cellspacing=’0′ class=’sub2′ cellpadding=’2′ width=’85%’ bordercolor=’black’>
<tr>
<th class=’header’ colspan=’1′ align=’center’>Id</th>
<th class=’header’ colspan=’1′ align=’center’>Date and Time</th>
<th class=’header’ colspan=’1′ align=’center’>Username</th>
<th class=’header’ colspan=’1′ align=’center’>Idea</th>
</tr>”;while($row = mysql_fetch_array($result))
{
echo “<tr>”;
echo “<td>” . $row[‘id’] . “</td>”;
echo “<td>” . $row[‘datetime’] . “</td>”;
echo “<td>” . $row[‘username’] . “</td>”;
echo “<td>” . $row[‘idea’] . “</td>”;
echo “</tr>”;
}
echo “</table>”;mysql_close($con);
?>[/CODE]

Is there any way I can also have a Delete button that only deletes that row? and Also is there a way that I can have a button that transferrs it into a another Table?

Thanks Guys,

Ash

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@trielephantJul 25.2007 — well, you can add a delete link with something like this:[code=php]echo '<a href="delete.php?id='.$row['id'].'">[delete this record]</a>';[/code]Then delete.php would look something like:[code=php]$id=$_GET['id'];
$sql="DELETE * FROM ideas WHERE id=$id";
mysql_query($sql);
header("Location: yourtable.php");[/code]
To move to another table would work similarly.
×

Success!

Help @Asho spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...