Jump to content

Problem with PHP/Mysql


Gruzin

Recommended Posts

hi guys, I want to display the result form db and add it some Edit and Delete function, here is my effort but think I'am not on  a correct way. Your ideas will be very appreciated.

P.S I won't post the Reslut script, it works ok, here is the delete function, which of course doesn't work...

[code]<?php
$con = mysql_connect("localhost","user","pass"); //connect to db
if(!$con){
  die('Error:'.mysql_error());
  }
mysql_select_db("user", $con); //select db

$query = "SELECT * FROM link_manager WHERE id ORDER BY id";
$result = mysql_query($query) or die("Error: " . mysql_error());
while($row = mysql_fetch_array($result))
$id = $row['id'];
$query2 = "DELETE * FROM link_manager WHERE id = $id";
$result2 = mysql_query($query2) or die("Error: " . mysql_error());
header( 'Location: http://www.mysite.net/links/') ;
mysql_close($con);
?>[/code]
Link to comment
Share on other sites

I've tested this and works ok:

$[code]query = "SELECT * FROM link_manager WHERE id ORDER BY id";
$result = mysql_query($query) or die("Error: " . mysql_error());
while($row = mysql_fetch_array($result))
echo $row['id'];[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.