i code this without the delete function, but when i started using it, there's and error.
need help with this code

<?php

$_GET['id'];

	$username = "root";
	$password = '123456';
	$hostname = "localhost";
	$db = mysql_connect($localhost, $username, $password)
	or die ("Unable to connect to mySQL".mysql_error());
	mysql_select_db('mynewdbase');

$del = "DELETE FORM newdbase WHERE id = $id";

$nres = mysql_query("$del);

?>
<HTML>
<BODY>
<form method = "get" action = "act1.php">
Storename: <select name="store">
<option value="">---Select---</option>
<option value="Aling Nena">Aling Nena</option>
<option value="Aling Tentay">Aling Tentay</option>
<option value="Aling Toyang">Aling Toyang</option>
</select>
<br>
Sales <input type = "text" name = "sales"><br>
Date  <input type = "text" name = "year" size = "3" value = "<?php echo date('Y'); ?>">
-<input type = "text" name = "month" size = "3" value = "<?php echo date('m'); ?>">
-<input type = "text" name = "day" size = "3" value = "<?php echo date('d'); ?>"><br>
<input type = "submit" name = "submit" value = "Save">
<input type = "reset" name = "clear" value = "Cancel">
</form>
</BODY>
</HTML>

<?php
if (isset($_GET['submit']))
{
	$username = "root";
	$password = '123456';
	$hostname = "localhost";
	$db = mysql_connect($localhost, $username, $password)
	or die ("Unable to connect to mySQL".mysql_error());

mysql_select_db('mynewdbase');

	$store = $_GET['store'];
	$sales = $_GET['sales'];
	$year = $_GET['year'];
	$month = $_GET['month'];
	$day = $_GET['day'];

$ans = "INSERT INTO newdbase VALUES ('$store', '$sales', '$year' ,'$month', '$day')";

	$result = mysql_query($ans);

	if($ans!='')
	echo '<br>Saving Successful';
	else
	echo '<br>Failed'. mysql_error();

$queryshow = "SELECT * FROM newdbase";
$result2 = mysql_query($queryshow);
$c = count($result2);
echo '<table border ="1">';
echo '<th>Storename</th><th>Sales</th><th>Date</th><th></th>';
if ($c>0)
	{
	while ($a=mysql_fetch_array($result2))
		{
			echo '<tr>';
			echo '<td><a href = "act1.php" ? id = $id></td>;
			echo '<td>'. $a['store'] . '</td>';
			echo '<td>'.  $a['sales'] . '</td>';
			echo '<td>'.  $a['year'] . '-'.$a['month'].'-'.$a['day'].'</td>';
			echo '</tr>';
		}
	}
echo '</table>';
}
?>

What error do you get?

Lol because of this

$id =  $_GET['id']; //you forgot to put the $id = 

	$username = "root";
	$password = '123456';
	$hostname = "localhost";
	$db = mysql_connect($localhost, $username, $password)
	or die ("Unable to connect to mySQL".mysql_error());
	mysql_select_db('mynewdbase');

$del = "DELETE FORM newdbase WHERE id = $id";

$nres = mysql_query("$del);

?>

you should try my site it might help you better :)

Lol because of this

$id =  $_GET['id']; //you forgot to put the $id = 

	$username = "root";
	$password = '123456';
	$hostname = "localhost";
	$db = mysql_connect($localhost, $username, $password)
	or die ("Unable to connect to mySQL".mysql_error());
	mysql_select_db('mynewdbase');

$del = "DELETE FORM newdbase WHERE id = $id";

$nres = mysql_query("$del);

?>

you should try my site it might help you better :)

It also might be useful to note that once quotes are opened, they must be closed. But in your instance, quotes aren't necessary on this line.

<?php
$id =  $_GET['id']; //you forgot to put the $id = 

	$username = "root";
	$password = '123456';
	$hostname = "localhost";
	$db = mysql_connect($localhost, $username, $password)
	or die ("Unable to connect to mySQL".mysql_error());
	mysql_select_db('mynewdbase');

$del = "DELETE FORM newdbase WHERE id = $id";

$nres = mysql_query($del); //Much better
?>

DROP tabble_name ;

don't condemn me, that is from heading ;)
Now, seriously PMC have got it!

i tried those but still i have error., i also tried my new code but everytime i select delete, it adds one more table, how come? here's my code:

<?php

    $username = "root";
    $password = "123456";    
    $hostname = "localhost";
    $db = mysql_connect($hostname, $username, $password)
    or die ("Unable to connect to mySQL".mysql_error());
    mysql_select_db('mynewdbase');

    $flag = $_GET['flag'];                        

if($flag==1)                                        
{
$id = $_GET['id'];
$del = "DELETE FROM newdbase WHERE id = '$id'";
$nres = mysql_query($del);


if(!$nres)                                                    
echo " Failed to delete:" . mysql_error();
else
echo " Deleting successful";
}
?>

<HTML>
<BODY>
<form method = "get" action = "act1.php">
Storename:<input type = "text" name = "store"><br>
Sales <input type = "text" name = "sales"><br>
Date  <input type = "text" name = "year" size = "3" value = "<?php echo date('Y'); ?>">
-<input type = "text" name = "month" size = "3" value = "<?php echo date('m'); ?>">
-<input type = "text" name = "day" size = "3" value = "<?php echo date('d'); ?>"><br>
<input type = "submit" name = "submit" value = "Save">
<input type = "reset" name = "clear" value = "Cancel">
</form>
</BODY>
</HTML>

<?php

    $store = $_GET['store'];
    $sales = $_GET['sales'];
    $year = $_GET['year'];
    $month = $_GET['month'];
    $day = $_GET['day'];

$ans = "INSERT INTO newdbase VALUES ('','$store', '$sales', '$year' ,'$month', '$day')";

    $result = mysql_query($ans);

    if($result!='')                                     
    echo '<br>Saving Successful';
    else
    echo '<br>Failed'. mysql_error();

$queryshow = "SELECT * FROM newdbase";
$result2 = mysql_query($queryshow);
$c = count($result2);
echo '<table border ="1">';
echo '<th>Action</th><th>Storename</th><th>Sales</th><th>Date</th>';
if ($c>0)
    {
    while ($a=mysql_fetch_array($result2))
        {
            echo '<tr>';
            echo '<td><a href = "act1.php?id= $id & flag = 1">Delete</a></td>'; 
            echo '<td>'. $a['store'] . '</td>';
            echo '<td>'.  $a['sales'] . '</td>';
            echo '<td>'.  $a['year'] . '-'.$a['month'].'-'.$a['day'].'</td>';
            echo '</tr>';
        }
    }
echo '</table>';

?>

Hi,

Is the issue resolved ? If not, try this code, which will tell you error.

<?php

    $username = "root";
    $password = "123456";    
    $hostname = "localhost";
    $db = mysql_connect($hostname, $username, $password) 
    or die ("Unable to connect to mySQL".mysql_error());
    mysql_select_db('mynewdbase') or die(mysql_error());

    $flag = $_GET['flag'];                        

if($flag==1)                                        
{
$id = $_GET['id'];
$del = "DELETE FROM newdbase WHERE id = '$id'";
$nres = mysql_query($del) or die(mysql_error());


if(!$nres)                                                    
echo " Failed to delete:" . mysql_error();
else
echo " Deleting successful";
}
?>

<HTML>
<BODY>
<form method = "get" action = "act1.php">
Storename:<input type = "text" name = "store"><br>
Sales <input type = "text" name = "sales"><br>
Date  <input type = "text" name = "year" size = "3" value = "<?php echo date('Y'); ?>">
-<input type = "text" name = "month" size = "3" value = "<?php echo date('m'); ?>">
-<input type = "text" name = "day" size = "3" value = "<?php echo date('d'); ?>"><br>
<input type = "submit" name = "submit" value = "Save">
<input type = "reset" name = "clear" value = "Cancel">
</form>
</BODY>
</HTML>

<?php

    $store = $_GET['store'];
    $sales = $_GET['sales'];
    $year = $_GET['year'];
    $month = $_GET['month'];
    $day = $_GET['day'];

$ans = "INSERT INTO newdbase VALUES ('','$store', '$sales', '$year' ,'$month', '$day')";

    $result = mysql_query($ans) or die(mysql_error());

    if($result!='')                                     
    echo '<br>Saving Successful';
    else
    echo '<br>Failed'. mysql_error();

$queryshow = "SELECT * FROM newdbase";
$result2 = mysql_query($queryshow) or die(mysql_error());
$c = count($result2);
echo '<table border ="1">';
echo '<th>Action</th><th>Storename</th><th>Sales</th><th>Date</th>';
if ($c>0)
    {
    while ($a=mysql_fetch_array($result2))
        {
            echo '<tr>';
            echo '<td><a href = "act1.php?id= $id & flag = 1">Delete</a></td>'; 
            echo '<td>'. $a['store'] . '</td>';
            echo '<td>'.  $a['sales'] . '</td>';
            echo '<td>'.  $a['year'] . '-'.$a['month'].'-'.$a['day'].'</td>';
            echo '</tr>';
        }
    }
echo '</table>';

?>

i think your code is same as mine., anyway, i dont get an error but my problem now is everytime i select delete, it only adds one more table., rather than deleting it

i tried those but still i have error., i also tried my new code but everytime i select delete, it adds one more table, how come? here's my code:

<?php

    $username = "root";
    $password = "123456";    
    $hostname = "localhost";
    $db = mysql_connect($hostname, $username, $password)
    or die ("Unable to connect to mySQL".mysql_error());
    mysql_select_db('mynewdbase');

    $flag = $_GET['flag'];                        

if($flag==1)                                        
{
$id = $_GET['id'];
$del = "DELETE FROM newdbase WHERE id = '$id'";
$nres = mysql_query($del);


if(!$nres)                                                    
echo " Failed to delete:" . mysql_error();
else
echo " Deleting successful";
}
?>

<HTML>
<BODY>
<form method = "get" action = "act1.php">
Storename:<input type = "text" name = "store"><br>
Sales <input type = "text" name = "sales"><br>
Date  <input type = "text" name = "year" size = "3" value = "<?php echo date('Y'); ?>">
-<input type = "text" name = "month" size = "3" value = "<?php echo date('m'); ?>">
-<input type = "text" name = "day" size = "3" value = "<?php echo date('d'); ?>"><br>
<input type = "submit" name = "submit" value = "Save">
<input type = "reset" name = "clear" value = "Cancel">
</form>
</BODY>
</HTML>

<?php

    $store = $_GET['store'];
    $sales = $_GET['sales'];
    $year = $_GET['year'];
    $month = $_GET['month'];
    $day = $_GET['day'];

$ans = "INSERT INTO newdbase VALUES ('','$store', '$sales', '$year' ,'$month', '$day')";

    $result = mysql_query($ans);

    if($result!='')                                     
    echo '<br>Saving Successful';
    else
    echo '<br>Failed'. mysql_error();

$queryshow = "SELECT * FROM newdbase";
$result2 = mysql_query($queryshow);
$c = count($result2);
echo '<table border ="1">';
echo '<th>Action</th><th>Storename</th><th>Sales</th><th>Date</th>';
if ($c>0)
    {
    while ($a=mysql_fetch_array($result2))
        {
            echo '<tr>';
            echo '<td><a href = "act1.php?id= $id & flag = 1">Delete</a></td>'; 
            echo '<td>'. $a['store'] . '</td>';
            echo '<td>'.  $a['sales'] . '</td>';
            echo '<td>'.  $a['year'] . '-'.$a['month'].'-'.$a['day'].'</td>';
            echo '</tr>';
        }
    }
echo '</table>';

?>

Its seems that all the files send action to act1.php. the deciding factor is flag and as I look at your messy code I cannot get it well (honestly). I will advice you to make class and use its object. Here is an example of how you can do that, completely untested

manager.php

class ManageSales{
	private var $conn;
	
	public function __construct(){
		$username = "root";
		$password = "123456";    
		$hostname = "localhost";
		$db = mysql_connect($hostname, $username, $password)
		or die ("Unable to connect to mySQL".mysql_error());
		mysql_select_db('mynewdbase');
		$this->conn = $db;
	
	}
	
	public function deleteData(){
		$id = $_GET['id'];
		$del = "DELETE FROM newdbase WHERE id = '$id'";
		$nres = mysql_query($del);

		if(!$nres){                                                    
			return false;
		}
		else{
			return true;
		}

	}
	
	public function addData(){
			$store = $_GET['store'];
			$sales = $_GET['sales'];
			$year = $_GET['year'];
			$month = $_GET['month'];
			$day = $_GET['day'];
			$ans = "INSERT INTO newdbase VALUES ('','$store', '$sales', '$year' ,'$month', '$day')";
			$result = mysql_query($ans);
			if($result!=0) {
				return true;
			}			
			else{
				return false;
			}
	}

}

acts1.php

include "manager.php"
mgr = new ManageSales();
if($flag==1)  {
	mgr.deleteData()
}
else{
	mgr.addData()
}

BTW that code is for PHP 5.x so if you work with PHP 4 it will need slight modification :)

tnx evstevemd, but im still on the basics :D don't know how to use class yet

Now if that is the case I will advice you to make different actions for delete and add files. That is, make one action on form to add_data.php and another action to delete_data.php

Are you trying to delete a table? or some records in it?

@ evstevemd tried that and it works., but i want it on the same page

@ Huakalero i want to delete a table and the values on it

here's my new code:

<?php

    $username = "root";
    $password = "123456";    
    $hostname = "localhost";
    $db = mysql_connect($hostname, $username, $password)
    or die ("Unable to connect to mySQL".mysql_error());
    mysql_select_db('mynewdbase') or die(mysql_error());

    $flag = $_GET['flag'];                        

if($flag=="1")                                        
{
$id = $_GET['id'];
$del = "DELETE FROM newdbase WHERE id = '$id'";
$nres = mysql_query($del);


if(!$nres)                                                    
echo " Failed to delete:" . mysql_error();
else
echo " Deleting successful";
}
?>

<HTML>
<BODY>
<form method = "get" action = "act1.php">
Storename:<input type = "text" name = "store"><br>
Sales <input type = "text" name = "sales"><br>
Date  <input type = "text" name = "month" size = "3" value = "<?php echo date('m'); ?>">
-<input type = "text" name = "day" size = "3" value = "<?php echo date('d'); ?>">
-<input type = "text" name = "year" size = "3" value = "<?php echo date('Y'); ?>"><br>
<input type = "submit" name = "submit" value = "Save">
<input type = "reset" name = "clear" value = "Cancel">
</form>
</BODY>
</HTML>

<?php

    $store = $_GET['store'];
    $sales = $_GET['sales'];
    $year = $_GET['year'];
    $month = $_GET['month'];
    $day = $_GET['day'];

$ans = "INSERT INTO newdbase VALUES ('','$store', '$sales', '$year' ,'$month', '$day')";

    $result = mysql_query($ans);

    if($result!='')                                     
    echo '<br>Saving Successful';
    else
    echo '<br>Failed'. mysql_error();

$queryshow = "SELECT * FROM newdbase";
$result2 = mysql_query($queryshow);
$c = count($result2);
echo '<table border ="1">';
echo '<th>Action</th><th>Storename</th><th>Sales</th><th>Date</th>';
if ($c>0)
    {
    while ($a=mysql_fetch_array($result2))
        {
            echo '<tr>';
            echo "<td><a href = \"act1.php?id=".$a["id"]."&flag=1\" >Delete</a></td>"; 
            echo '<td>'. $a['store'] . '</td>';
            echo '<td>'.  $a['sales'] . '</td>';
            echo '<td>'.  $a['month'] . '-'.$a['day'].'-'.$a['year'].'</td>';
            echo '</tr>';
        }
    }
echo '</table>';

?>

Now I suspect something is wrong with your if..else
Here is my suggestion:
add the files in the comments below

if($flag=="1"){
    //paste code of first file
}
else{
    //paste code for second file
}

Paste two files differently if you will still face errors

@ Huakalero i want to delete a table and the values on it

Just use Drop Table Sql statement. Dropping table destroys data therein too

the code remove the values of my table but my prob now is i dont know how to remove the table (the <tr> and <td>) when i select delete

the code remove the values of my table but my prob now is i dont know how to remove the table (the <tr> and <td>) when i select delete

What do you mean by that?

here's the sample output:

Storename:
Sales
Date - -


Saving Successful
Action Storename Sales Date
Delete slap1 123123.00 8-8-2010
Delete slap2 2123123.00 8-8-2010
Delete slap3 123142.00 8-8-2010

when delete is selected:

Saving Successful
Action Storename Sales Date
Delete slap1 123123.00 8-8-2010
Delete slap2 2123123.00 8-8-2010
Delete 000000.00 0-0-0

the values are deleted but the table still remains

You have select mynewtable and delete from newtable??? is this correct??

sorry mynewdbase and newdbase

here's the sample output:

Storename:
Sales
Date - -


Saving Successful
Action Storename Sales Date
Delete slap1 123123.00 8-8-2010
Delete slap2 2123123.00 8-8-2010
Delete slap3 123142.00 8-8-2010

when delete is selected:

Saving Successful
Action Storename Sales Date
Delete slap1 123123.00 8-8-2010
Delete slap2 2123123.00 8-8-2010
Delete 000000.00 0-0-0

the values are deleted but the table still remains

mysql_query("DROP TABLE table_name");