只是保留内容,你把下面的代码改改就行了:
php
$html_with_a_tags ='a href="" target="_blank" class="keylink"玉石/a';
//保存一个超链接字符串变量,php当字符串处理
$txt = strip_tags($html_with_a_tags);
//用strip_tags去掉html标签
echo $txt;
//输出结果
至于你的说什么object,把它调进去就行了
a href="delete.php?id=xxx" 删除/a
foreach遍历数据的时候 写上id值,然后delete.php页面执行删除操作.
要么你把连数据库的页面包含到 delete.php(不推荐)
要么 都写在一个页面,然后switch case 判断操作 接受id 然后执行
a href="delete.php?act=delid=xxx" 删除/a 这样比较推荐
delete.php页面里
连好数据库 switch($act=$_GET['act']){ case 'del': .........;break;case....}
preg_replace正则匹配,去除所有a链接地址,并且保留里面a里面的内容
preg_replace("#a[^]*(.*?)/a#is", "$1",$body);
ereg_replace正则匹配:
ereg_replace("]*|/a","",$content);
ereg_replace函数匹配以"a "开头,中间除以外的所有字符,再以结尾的字符串或匹配""字符.匹配到的字符串赋为空.
这里详细的记载了jquery ajax的使用方法.
逻辑代码可以用php
不刷新页面异步传输只能用js中的ajax技术
删除的功能,你这么写完全错了.我建议删除的代码写在单独的文件.删除文件我暂时命名为:delete.php.
a.php文件里的这句
echo "tda href='lochoes-testcd.php?ID=".$row['ID']."Name=".$row['Name']."Sex=".$row['Sex']."Dept=".$row['Dept']."'删除/a/td/tr";
修改为 echo "tda href='lochoes-testcd.php?ID=".$row['ID']."' onclick=' return del();'"删除/a/td/tr";
而且在head/head加这么段代码:
script type='text/javascript'
function del(){
if(confirm('是否删除?')){
return true;
else
return false;
}
/script
而delete.php文件这么写:
$id = $_GET['ID'];
$db=mysql_connect("localhost","root","root")or die("链接数据库失败");
mysql_select_db("files")or die("链接数据表库失败");
$sql ="delete from students where id='$id'";
mysql_query($sql);
①如果用的是函数,比如连接MySQL,$conn=mysql_connect($db_host,$db_username,$db_password)为连接MySQL数据库的资源,关闭此连接用mysql_close($conn).
②如果用的是PDO,如pdo=new PDO()为PDO连接,关闭连接将其设为null即可,即pdo=null.
希望能帮上你.
以上就是土嘎嘎小编为大家整理的php删除数据库的超链接相关主题介绍,如果您觉得小编更新的文章只要能对粉丝们有用,就是我们最大的鼓励和动力,不要忘记讲本站分享给您身边的朋友哦!!