?

Search Help Board

PHP FAQ
PHP Articles
PHP Help
Bulletin Board

PHP Manual (NEW!)
First Time PHP'ers
Help with programming
Sql assignment help
PHP Homework Help


C# Help

?
?Deleting a row from mysql database
Author:??(---.cinci.rr.com)
Date:???10-18-03 17:11

I am trying to learn SQL and PHP. I have created a database I can read and load info into, but I can't delete rows. I have a trial page if anyone can help I would greatly appreciate it.

http://www.wearebusiness.com/php/catalog/deleterow2.php

http://www.wearebusiness.com/php/catalog/deleterow.php


The code I am tring to use is posted below:





include ($_SERVER['DOCUMENT_ROOT'].'/../misc.inc');
/* include("misc.inc"); */
$connection = mysql_connect($host,$user,$password)
or die ("couldn't connect to server");
$db = mysql_select_db($database,$connection)
or die ("Couldn't select database");
if(!$submit)
{
$result = mysql_query("select * from Pet order by petID");
while($r=mysql_fetch_array($result))
{
$petID=$r["petID"];
$petName=$r["petName"];
$petDescription=$r["petDescription"];
$price=$r["price"];
$pix=$r["pix"];
?>





}?>

}?>
{
$sql = "DELETE FROM Pet WHERE delete=$petID";
$result = mysql_query($sql);
echo "Record deleted!";
}?>

?Topics Author? Date
?Deleting a row from mysql database??new
John 10-18-03 17:11?
?Re: Deleting a row from mysql database??new
martin 10-19-03 01:15?
?Re: Deleting a row from mysql database??new
John 10-19-03 03:53?
?Re: Deleting a row from mysql database??new
bastien 10-19-03 08:55?
Go to Top??|??Go to Topic??|??Flat View??|??Search?
??|??
New Topic
?Reply To This Message
?Your Name:
?Your Email:
?Subject:
Email replies to this thread, to the address above.
??wrote: > > I am trying to learn SQL and PHP. I have created a database I > can read and load info into, but I can't delete rows. I have > a trial page if anyone can help I would greatly appreciate it. > > http://www.wearebusiness.com/php/catalog/deleterow2.php > > http://www.wearebusiness.com/php/catalog/deleterow.php > > > The code I am tring to use is posted below: > > > > >
> include ($_SERVER['DOCUMENT_ROOT'].'/../misc.inc'); > /* include("misc.inc"); > */ > $connection = mysql_connect($host,$user,$password) > or die ("couldn't connect to server"); > $db = mysql_select_db($database,$connection) > or die ("Couldn't select database"); > if(!$submit) > { > $result = mysql_query("select * from Pet order by petID"); > while($r=mysql_fetch_array($result)) > { > $petID=$r["petID"]; > $petName=$r["petName"]; > $petDescription=$r["petDescription"]; > $price=$r["price"]; > $pix=$r["pix"]; > ?> > > echo $petName;?>
> > > }?> >
> }?> > { > $sql = "DELETE FROM Pet WHERE delete=$petID"; > $result = mysql_query($sql); > echo "Record deleted!"; > }?> ">??

Provided By
Phorum