PHP-MySQL-删除行 [英] PHP - MySQL - Delete Row

查看:73
本文介绍了PHP-MySQL-删除行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不太确定自己在做什么错.我正在尝试使用此代码删除整行,但无法正常工作.没有错误发生,它会打印出已删除的行,但是当我去看看它不起作用时.有什么想法吗?

I am not too sure what i am doing wrong. i am trying to delete the entire row with this code but it is not working. No error is happening it prints the line that it was deleted but when i go and have a look it is not working. Any thoughts?

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

mysql_select_db("theobse1_scores", $con);

$sql="DELETE FROM times WHERE id='$id'";

if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "1 record deleted go back to delete another!";

mysql_close($con)
?>

推荐答案

我使用此代码可以正常工作!

I got it working using this code!

<?php
$id =$_REQUEST['id'];

$con = mysql_connect("localhost","username","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("database", $con);

// sending query
mysql_query("DELETE FROM times WHERE id = '$id'")
or die(mysql_error());      

?>

这篇关于PHP-MySQL-删除行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆