Get support from Xavier Media
It is currently Sun Dec 08, 2013 2:46 pm

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: have problem with delete query
PostPosted: Thu Jan 29, 2009 3:29 pm 
Offline
Rookie (I'm probably spamming)
Rookie (I'm probably spamming)

Joined: Thu Jan 29, 2009 3:17 pm
Posts: 2
Points: 0
i have problem with my delete query
i have 3 php file
first one name : bordel.php
<?php
/* Program name: bordel.php
* Description: Program builds a selection list
* from the database to select the borrower to delete.
*/
?>
<html>
<head><title>Delete Borrower</title></head>
<body bgcolor="#F5F5F5" >
<font color= "#000099" face="Garamond">
<b><h2>Select the Borrower You Want to Delete from the Database:</h2><br>

<?php
$user="root";
$host="localhost";
$password="";
$database = "joomla15";

$cxn = mysqli_connect($host,$user,$password,$database)
or die ("couldn't connect to server");
$query = "SELECT DISTINCT borrower_name FROM borrower ORDER BY borrower_name";
$result = mysqli_query($cxn,$query)
or die ("Couldn't execute query.");


/* create form containing selection list */
echo "<form action='deleteborrower.php' method='POST'>
<select name='borrower_name'>\n";

while ($row = mysqli_fetch_assoc($result))
{
extract($row);
echo "<option value='$borrower_name'>$borrower_name\n";
}
echo "</select>\n";
echo "<input type='submit' value='Select Borrower to Delete'>
</form>\n";
?>
</body></html>

-------------------------------------------------------------------------
second php file


<!- Program name: deleteborrower.php
Description: Script displays a form to edit the borrower>

<html>
<head><title>Edit Selected Borrower</title></head>
<body bgcolor="#F5F5F5">
<font color= "#000099" face="Garamond" size="18"><b>
<?php

$labels = array( "borrowerID"=>"ID:",
"borrower_name"=>"Name:",
"borrower_phone"=>"Phone:",
"borrower_email"=>"Email:",
"borrower_lateTime"=>"Late on return times:",
"borrower_status"=>"Status:");
$user="root";
$host="localhost";
$password="";
$database = "joomla15";

foreach ($_POST as $field => $value)




$cxn = mysqli_connect($host,$user,$password,$database)
or die ("couldn't connect to server");
$query = "SELECT * FROM borrower
WHERE borrower_name='$value'";


$result = mysqli_query($cxn,$query)
or die ("Couldn't execute query");


echo "<p style='font-size: large; font-weight: bold'>
Are You Sure You Want to Delete $value 's Information ?</p><hr />";


$query="SELECT * FROM borrower WHERE borrower_name= '$_POST[borrower_name]'";
$result=mysqli_query($cxn,$query)
or die("Couldn't execute query");

/* Display results in a table */

echo "<table cellspacing='10'>";

echo "<td><b><u>ID</td> <td><b><u>Name</td> <td><b><u>Phone</td> <td><b><u>Email</td> <td><b><u>Late </td>

<td><b><u>Status</td>";
echo "<tr><td colspan='10'><hr/></td></tr>";
while($row = mysqli_fetch_assoc($result))
{

extract($row);
echo "<tr>\n
<td>$borrowerID</td>\n
<td>$borrower_name</td>\n
<td>$borrower_phone</td>\n
<td>$borrower_email</td>\n
<td>$borrower_lateTime time(s) </td>\n
<td>$borrower_status</td>\n

</tr>\n";
echo "<tr><td colspan='10'><hr /></td></tr>\n";
}
echo "</table>\n";

echo "<form action='processform1.php' method='POST'>
<p><table align='left'>\n";


echo "<tr><td>&nbsp;</td>
<td style='text-align: left' >
<input type='submit' value='Yes'>";
echo "</td></tr></table>
</div>
</form>";






?>
</body></html>

---------------------------------------------------------
3rd php file proccessform.php

<html>
<head><title>borrower</title></head>
<body bgcolor="#F5F5F5">
<font color= "#000099" face="Garamond">
<?php
$user="root";
$host="localhost";
$password="";
$database ="joomla15";


foreach ($_POST as $field => $loving)



$cxn = mysqli_connect($host,$user,$password,$database)
or die ("couldn't connect to server");

echo $sql;// this is the query variable



$query = "DELETE FROM borrower WHERE borrower_name='$POST'[borrower_name]'" ;

mysqli_query($cxn, $query)
or die ("Couldn't execute query");

echo "<h2>Borrower Is Deleted!</h2>";





?>
</body></html>

-------------------------------------------------------------------

it gave me an answer your borrower has been deleted but its fake because i found that nothing has been deleted !! what i should do ? what is the problem with my scripts?


Report this post
Top
 Profile Send private message E-mail  
Reply with quote  
 Post subject: Re: have problem with delete query
PostPosted: Thu Jan 29, 2009 4:32 pm 
Offline
XavierForum.com Admin
XavierForum.com Admin
Super VIP Member
Super VIP Member
User avatar

Joined: Tue Mar 15, 2005 4:37 pm
Posts: 1082
Location: Sweden
Points: 1500
You need to correct this in your code:
Code:
'$POST'[borrower_name]'


Correct should be
Code:
'$_POST[borrower_name]'

_________________
Xavier Media®
Join me at LinkedIn | Get your latest blog post in your signature you too


Report this post
Top
 Profile Send private message  
Reply with quote  
 Post subject: Re: have problem with delete query
PostPosted: Fri Jan 30, 2009 2:20 pm 
Offline
Rookie (I'm probably spamming)
Rookie (I'm probably spamming)

Joined: Thu Jan 29, 2009 3:17 pm
Posts: 2
Points: 0
i did it but still have same problem , maybe its not able to move the information from the deleteborrowers at all ! so what should i do ? !


Report this post
Top
 Profile Send private message E-mail  
Reply with quote  
 Post subject: Re: have problem with delete query
PostPosted: Fri Jan 30, 2009 6:19 pm 
Offline
XavierForum.com Admin
XavierForum.com Admin
Super VIP Member
Super VIP Member
User avatar

Joined: Tue Mar 15, 2005 4:37 pm
Posts: 1082
Location: Sweden
Points: 1500
Instead of just printing that the borrower was deleted from the database you should print the name of the borrower too. That way you can see what's actually sent.

/Bylla

_________________
Xavier Media®
Join me at LinkedIn | Get your latest blog post in your signature you too


Report this post
Top
 Profile Send private message  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Registered users: No registered users


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron

Portal » Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
[
SEO MOD © 2007 StarTrekGuide ]