/    Sign up×
Community /Pin to ProfileBookmark

Deleting a field.

I am trying my best to do a user interface script that with a click of a link it will remove a record from a table. This is what I have come up with so far.

[code=php]
$connection = mysql_connect($host, $user, $password) or die (“Error with the connection to server. “);
$db = mysql_select_db($database, $connection) or die (“Could not connect to Database. “);
$query = “SELECT * FROM tbllinks”;
$result = mysql_query($query) or die (“Query could not be executed. “);

echo “<table>”;

while ($row = mysql_fetch_array($result))
{
extract($row);
echo “<tr><td>” . $linkURL . “</td><td>” . $linkName . “</td><td><a href=””>remove link</td></tr>”;
}

echo”</table>”;
mysql_close();

[/code]

I would like it to be to where when the user clicks on the “remove link” link, it will delete that specified record. I know the SQL for that is something along the lines of..

[code=php]

Delete From ‘tbllinks’ Where ‘linkid’ = $linkid

[/code]

..but don’t know how to get it to how I want to get it.

If someone could please help me or point me in the right direction I would much appreciate it. Thank you for your time.

-Cesar

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@ShrineDesignsFeb 06.2006 — if you want "remove" a specific column in a row, try thisUPDATE <span><code>tbl_links</code></span> SET <span><code>column</code></span> = '' WHERE <span><code>link_id</code></span> = '$linkid'
Copy linkTweet thisAlerts:
@ForeverIriseauthorFeb 06.2006 — I don't want to delete a Column, I want to delete a single record from the table. In the little bit of code I put, it extracts the fields from a table called "tblLinks" and puts it in a tabular form. In each row of the table created it puts in the following information:

Link URL and Link Name followed by a link "remove link".

Repeat..

Repeat..

What I want to happen is that when they click on the "remove link" link, it will remove that specified row from tblLinks.

Hope I didn't confuse anyone.
Copy linkTweet thisAlerts:
@chazzyFeb 06.2006 — try something like this:

[code=php]
$delete = "DELETE FROM table_name WHERE id=something";
$resultd = mysql_query($delete) or die("Unable to delete record");
[/code]
×

Success!

Help @ForeverIrise 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.25,
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,
)...