[advanced search]
 

Go Back   NamePros.com > Discussion > Web Design & Development > Programming

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.


Closed Thread
 
LinkBack Thread Tools
Old 07-05-2006, 03:49 PM   #1 (permalink)
NamePros Regular
 
Join Date: Dec 2005
Posts: 206
270.00 NP$ (Donate)

wackyjoe is on a distinguished road


Having trouble with delete

Hi there,

I made this site for a client, but i cant get the delete page to work.

All it has to do is when deleted is clicked it has 2 add the fields to another database and delete it from the oiginal.

I cant manage to get it to add itself to the other database and when i put in the delete from original it just dosent work.

Any help is appreciated.

Heres the code:


PHP Code:
<?php


$host
="localhost"; // Host name
$username="wackyjoe"; // Mysql username
$password="******"; // Mysql password
$tbl_name="calls2"; // Table name

// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");

$sql="SELECT id,Date,Time,Name,DOB,Address,Notes,inum FROM calls2 ORDER BY id DESC";
$result = mysql_query($sql);


?>
<table width="723" border="0" cellspacing="1" cellpadding="0">
<tr>
<td width="721"><form name="form1" method="post" action="">
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<td width="50" bgcolor="#FFFFFF">&nbsp;</td>
<td colspan="7" bgcolor="#FFFFFF"><strong>Please Select a Checkbox and hit Delete.</strong></td>
</tr>
<tr bgcolor="#00CC66">
<td align="center"><strong>Delete</strong></td>
<td width="136" align="center"><strong>Date</strong></td>
<td width="79" align="center"><strong>Time</strong></td>
<td width="94" align="center"><strong>Name</strong></td>
<td width="80" align="center"><strong>DOB</strong></td>
<td width="150" align="center"><strong>Address</strong></td>
<td width="81" align="center"><strong>Notes</strong></td>
</tr>
<?php
while($rows=mysql_fetch_array($result, MYSQL_ASSOC)){
$id = $rows['id'];
$date = $rows['Date'];
$time =$rows['Time'];
$name = $rows['Name'];
$dob = $rows['DOB'];
$address = $rows['Address'];
$notes = $rows['Notes'];
?>
<tr>
<td align="center" bgcolor="#FFFFFF"><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<? echo $rows['id'] ?>"></td>
  <td style="background-color: #FFFFFF;"><? echo $rows['Date']; ?></td>    
  <td style="background-color: #FFFFFF;"><? echo $rows['Time']; ?></td>
  <td style="background-color: #FFFFFF;"><? echo $rows['Name']; ?></td>
  <td style="background-color: #FFFFFF;"><? echo $rows['DOB']; ?></td>
  <td style="background-color: #FFFFFF;"><? echo $rows['Address']; ?></td>
  <td style="background-color: #FFFFFF;"><a href="notes.php?id=<? echo $rows['id']; ?>" target="_blank">View Notes</a></td>
</tr>
<tr>
<?
}
?>
<td colspan="8" align="center" bgcolor="#FFFFFF"><input name="delete" type="submit" id="delete" value="Delete"></td>
</tr>
<?
if($delete){
for(
$i=0;$i<$count;$i++){
$del_id = $checkbox[$i];
$sql = "
INSERT INTO calls (id, deleted, Date, Time, Name, DOB, Address, Notes,
    inum)
    VALUES
(
'', 1,  ' $date', ' $time',
'$name', '$dob', '$address',
'$notes') "
;
$result = mysql_query($sql);

if(
$result){
echo
"<meta http-equiv=\"refresh\" content=\"0;URL=delete.php\">";
}
else
{
echo
'Sorry and Error Occured';
}
}
}
mysql_close();
?>

</table>
</form>
</td>
</tr>
</table>
wackyjoe is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Site Sponsors
Advertise your business at NamePros

All times are GMT -7. The time now is 08:00 AM.


Powered by: vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
Template-Modifications by TMS
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85