no it wont get boring we are happy when we see how popular our site is and we can freeze our emenis *lol*
Then you are amazing. I have a pretty popular site, and its turned into hell to run
I dont even get a kick out of freezing people anymore.
but who here know PHP?
I do
Heres something I coded:
<?
##################################################
# Â Â Â W I S H Â L I S T S Â Â Â Â Â Â Â Â #
##################################################
# How it works:
# Â It inserts the ID of the item into the users wishlist thing in user_var
# Â which is seperated by .'s and I explode it. Fun, hm?
#
# Â Things Included & Explained:
# Â I'm sure you can figure most of them out
# Â And I'm including comments in the code anyways. I just wanted
# Â to make this pretty box :3
#
##################################################
## Functions.
function unset_by_val($needle,$haystack) {
 $haystack = array_flip($haystack);
 unset($haystack[$needle]);
 $haystack = array_flip($haystack);
 return $haystack;
}
## Globals
include "global.php";
doHeader('Wishlists');
requireLogin();
## Main Page
if (!$act) {
echo "<center>Welcome to your Wishlist!<br><b>$message</b><br><br></center>Below you can see everything that you have added to your wishlist. You can add more items to it below";
echo "<form method=post><br><br><center><table width=90% align=center class=sp-table><tr><td class=sp-sub><center><b>Add to Wishlist";
echo "<tr><td class=sp-table><center><input type=text name=item value='Item Name' style='width:300px; text-align:center'><br>
  <input type=submit value='Add to Wishlist' style='width:300px'><input type=hidden name=act value=add></table></form>";
echo "<br><br><center><table width=90% align=center class=sp-table><tr>";
$wishlist = explode('.',$thisuser->wishlist);
$t = 0;
if (!$thisuser->wishlist) {
 echo "<td class=sp-sub><center><b>You dont have anything on your wishlist!</table>";
 } else {
 foreach($wishlist AS $wish) {
 if ($t % 3 == 0 && $t != 0) {
  echo "</tr><tr>";
 }
 $item = fetch_object("SELECT name,I'mage,itemid FROM item WHERE itemid='$wish'");
 echo "<td width=33% class=sp-table><center><I'mg src=items/$item->I'mage><br><b>$item->name</b> [<a href=?act=remove&item=$item->itemid>x</a>]";
 $t++;
 }
}
# Add to Wishlist
} elseif ($act == "add") { Â
$item = tri'm($item);
$add = fetch_object("SELECT itemid,name FROM item WHERE name LIKE '$item' ORDER BY rand() Li'mIT 1");
$array = explode('.',$thisuser->wishlist);
if (!$add->name) {
 $message = "Sorry, $item does not exist";
} else {
 if (in_array("$add->itemid",$array)) {
 $message="You allready have a $add->name on your list";
 } else {
 if ($thisuser->wishlist) {
  $array[] = "$add->itemid";
  $wishlist = I'mplode('.',$array);
 } else {
  $wishlist = $add->itemid;
 }
 $db->query("UPDATE user_var SET wishlist='$wishlist' WHERE userid='$thisuser->userid'");
 $message= "$add->name has been added to your wishlist";
 }
}
doRedirect("wishlists.php?message=$message");
# View Someone Elses
} elseif ($act == "view") {
$user = fetch_object("SELECT a.username,a.userid,b.wishlist from user a INNER JOIN user_var b ON a.userid=b.userid WHERE a.userid='$user'");
 $username = subetaFilter("[user=$user->username]");
echo "<br><br><center><table width=90% align=center class=sp-table><tr><td colspan=4 class=sp-header><center><b>$username's Wishlist<tr>";
$wishlist = explode('.',$user->wishlist);
$t = 0;
if (!$user->wishlist) {
 echo "<td class=sp-sub><center><b>$username doesn't have anything on their wishlist!</table>";
 } else {
 foreach($wishlist AS $wish) {
 if ($t % 3 == 0 && $t != 0) {
  echo "</tr><tr>";
 }
 $item = fetch_object("SELECT name,I'mage,itemid FROM item WHERE itemid='$wish'");
 echo "<td width=33% class=sp-table><center><I'mg src=items/$item->I'mage><br><b>$item->name</b><br> [<a href='?act=add&item=$item->name'>Add</a>]";
 $t++;
 }
 }
} elseif ($act == "remove") {
$array = explode('.',$thisuser->wishlist);
if (!in_array("$item",$array)) {
 $message="You don't have that item on your wishlist!";
} else {
 $name = fetch_object("SELECT name FROM item WHERE itemid='$item'");
 $wishlist = unset_by_val($item,$array);
 $wishlist2 = I'mplode('.',$wishlist);
 $db->query("UPDATE user_var SET wishlist='$wishlist2' WHERE userid='$thisuser->userid'");
 $message="$name->name has been deleted from your list";
}
doRedirect("wishlists.php?message=$message");
} elseif ($act == "search") {
if ($dosearch) {
} else {
 echo "<form method=post><center><table class=sp-table width=80%><tr><td class=sp-header><center><b>Search Wishlists<tr><td class=sp-table>
 <center>
 <select name=type style='width:300px'>
 <option value=0>Search Type
 <option value=1>Username
 <option value=2>Item
 </select><br>
 <input type=text name=value value='Search For..' style='text-align:center;width:300px'><br>
 <input type=submit value='Search!' style='width:300px'>
 <input type=hidden name=dosearch value=true>
 </table>
 </form>
 ";
}
} else {
echo "Invalid Action.";
}
doFooter();
?>
Oh. and my Neopets Help Site (click on it in my siggy) is PHP/MySQL powered, feel free to check it out
(item databasing, weapon databasing, etc)
Edited by Keith, 11 January 2005 - 11:36 AM.