Database

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
pinkygal
Forum Newbie
Posts: 8
Joined: Tue Jan 21, 2003 7:54 am

Database

Post by pinkygal »

hi,
i want to combine the edit or delete the user information after i have sucessfully gotten my search result. How do I go about doing it?
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

You need to give a lot more information that this. Do you have any code you are working on? What search result? What user information do you want to edit/delete? We need to know as much as possible in order to help you.

Mac
pinkygal
Forum Newbie
Posts: 8
Joined: Tue Jan 21, 2003 7:54 am

Post by pinkygal »

I am developing an address book that contains the user's first name, last name, email, contact, address and occupation. It includes a search function to search for the particular user. When i get the search result, there suppose to be two buttons(one for editing and the other for deleting) the user's information. However, I do not know how to go about doing it. And is it possible for the user to view his updated information after he has change his information and click on update? if yes, how can i acheive it? And is my code correct for the two submit buttons that I mentioned earlier?

<html>
<head>
<title>Search Result</title>
</head>
<body>
<?php
$Pattern=".+@+\..+";
if($fname="")||((is_numeric($fname))){
echo "Please enter a valid First Name!<a href="search.html">BACK</a>";
}elseif ($lname="")||((is_numeric($lname))){
echo "Please enter a valid Last Name!<a href="search.html">BACK</a>";
}elseif($address=""){
echo "Please enter your Address!<a href="search.html">BACK</a>";
}elseif(eregi($Pattern,$email)){
echo "Please enter a valid email!<a href="search.html">BACK</a>";
}elseif($occupation="")||(is_numeric($occupation)){
echo "Please enter a valid Occupation!<a href="search.html">BACK</a>";
}else{
$Host="localhost";
$User="0000985B";
$Password="0000985B";
$DBName="0000985B";
$TableName="AddressBook";

$Link=mysql_connect($Host,$User,$Password);

$Query="SELECT *
FROM $TableName
WHERE FirstName=$Array[FirstName],
LastName=$Array[LastName],
Address=$Array[Address],
Email=$Array[Email],
Occupation=$Array[Occupation]";
$Result=mysql_db_query($DBName,$Query,$Link);

print("<table border=1 width=\"75%\" cellspacing=2
cellpadding=2 align=center>\n");

print("<tr align=center valign=top>\n");
print("<td align=center valign=top>Name</td>\n");
print("<td align=center valign=top>Contact</td>\n");
print("<td align=center valign=top>Address</td>\n");
print("<td align=center valign=top>Email</td>\n");
print("<td align=center valign=top>Occupation</td>\n");
print("</tr>\n");

while($Row=mysql_fetch_array($Result)){
print("<tr align=center valign=top>\n");
print("<td align=center valign=top>$Row[FirstName]
$Row[LastName]</td>\n");
print("<td align=center valign=top>$Row[Contact]</td>\n");
print("<td align=center valign=top>$Row[Address]</td>\n");
print("<td align=center valign=top>$Row[Email]</td>\n");
print("<td align=center valign=top>$Row[Occupation]</td>\n");
print("</tr>\n");
}
print("<form action=delete.php method=post>\n");
print("<input type=submit name=submit value=submit>");
print("</form>");
print("<form action=edit.php method=post>\n");
print("<input type=button name=edit value=edit>");
print("</form>");
mysql_close($Link);
print("</table>\n");

?>
</body>
</html>
Post Reply