Jump to content

[SOLVED] need help making a search on a file


darkfreaks

Recommended Posts

ok so i have a feature called safety box which is a box that stores your items. i want to make a search for it but with all the complicated coding i wouldn't know where to start, can anyone, tell me how i would go about this?

 

 

safetybox.php

<?php

/*

Safety Box (safety_box.php)

*/

$page_title = "Safety Box";
$rank_check = 1;
include "header.inc.php";


$sum_items = mysql_query("SELECT sum(stock) AS stock FROM safety_box WHERE owner = '$userid' AND game = '$game'");
$sum_items2 = mysql_fetch_array($sum_items);



print "$openHTML";

ECHO <<<END

<p align=center><a href=item_helper.php?game=$game>Item Helper</A> | <a href=myitems.php?game=$game>My Items</a> | <a href=myshop.php?game=$game>My Shop</a> | <a href=battle_items.php?game=$game>Equipped Items</a> | <a href=safety_box.php?game=$game>Safety Box</a></p>

<form action=safety_box.pro.php?game=$game method=post>
<CENTER><FONT SIZE="-1"><B>You have $sum_items2[stock]
items in your safe.</B></FONT><br><br>


Please use these links to go to pages in your safe.<br>(some people may have less or more pages, this cant be helped right now, just ignore the pages you dont have, there is also a previous 50 and a next 50 at the bottom of the page)<br><br>

<a href=safety_box.php?game=$game&start=0>Page 1</a> | <a href=safety_box.php?game=$game&start=50>Page 2</a> | <a href=safety_box.php?game=$game&start=100>Page 3</a> | <a href=safety_box.php?game=$game&start=150>Page 4</a> | <a href=safety_box.php?game=$game&start=200>Page 5</a> | <a href=safety_box.php?game=$game&start=250>Page 6</a> | <a href=safety_box.php?game=$game&start=300>Page 7</a> | <a href=safety_box.php?game=$game&start=350>Page 8</a> | <a href=safety_box.php?game=$game&start=400>Page 9</a> | <a href=safety_box.php?game=$game&start=450>Page 10</a>| <a href=safety_box.php?game=$game&start=500>Page 11</a> | <a href=safety_box.php?game=$game&start=550>Page 12</a>| <a href=safety_box.php?game=$game&start=600>Page 13</a> | <a href=safety_box.php?game=$game&start=650>Page 14</a>| <a href=safety_box.php?game=$game&start=700>Page 15</a> | <a href=safety_box.php?game=$game&start=750>Page 16</a>

<P><FONT SIZE="-1"><TABLE CELLSPACING=1 CELLPADDING=10 WIDTH="95%" BGCOLOR="$topAndBottomBG">
   <TR BGCOLOR="$topAndBottomBG">
      <TD COLSPAN=6 HEIGHT=45>
         <CENTER><FONT SIZE="+2" COLOR="$topAndBottomText">My
         Safety Box</FONT></CENTER>
      </TD>
   </TR><form action=safetybox.pro.php?game=$game method=post>
   <TR BGCOLOR="$topAndBottomBG">
      <TD WIDTH=85>
         <CENTER><FONT SIZE="-1">Image</FONT></CENTER>
      </TD>
      <TD WIDTH=90>
         <CENTER><FONT SIZE="-1">Name</FONT></CENTER>
      </TD>
      <TD WIDTH=45>
         <CENTER><FONT SIZE="-1">Stock</FONT></CENTER>
      </TD>
      <TD WIDTH=55>
         <CENTER><FONT SIZE="-1">Value</FONT></CENTER>
      </TD>
      <TD>
         <CENTER><FONT SIZE="-1">Descrition</FONT></CENTER>
      </TD>
      <TD WIDTH=100>
         <CENTER><FONT SIZE="-1">Remove</FONT></CENTER>
      </TD>
   </TR>

END;



$z = 1;

if (!$start) { $start = 0; }
$start2 = $start + 50;
$start3 = $start - 50;






$find_items2 = mysql_query("SELECT * FROM safety_box WHERE owner = '$userid' AND game = '$game' ORDER BY item_id LIMIT $start,50");


while ($find_items = mysql_fetch_array($find_items2))
{

$find_item2 = mysql_fetch_array(mysql_query("SELECT * FROM items2 WHERE id ='$find_items[item_id]' AND game = '$game'"));
$id = $find_items[id];

print "<TR BGCOLOR=\"$maincellColor\">
      <TD WIDTH=85>
         <CENTER><IMG SRC=\"images/user_images/opg_$game/items/item_$find_item2[id].gif\"></CENTER>
      </TD>
      <TD WIDTH=90>
         <CENTER><FONT SIZE=\"-1\"><B>$find_item2[item_name]</B></FONT><BR>
         </CENTER>
      </TD>
      <TD WIDTH=45>
         <CENTER><FONT SIZE=\"-1\">$find_items[stock]</FONT></CENTER>
      </TD>
      <TD WIDTH=55>
         <CENTER><FONT SIZE=\"-1\">$find_item2[item_value]</FONT></CENTER>
      </TD>
      <TD>
         <P><FONT SIZE=\"-1\">$find_item2[item_desc]</FONT></P>
      </TD>
      <TD WIDTH=100>
         <CENTER><FONT SIZE=\"-1\">Remove:
         <INPUT TYPE=text NAME=\"remove[$id]\" VALUE=\"0\" SIZE=7 MAXLENGTH=6><BR>
         item(s)</FONT></CENTER>
      </TD>
   </TR>";
}

if ($find_item2 > ($start + 50))
{
	$nextThree = "<a href=safety_box.php?game=$game&start=$start2>Next 50</a>";
}
else
{
	$nextThree = "<font color=#cccccc>Next</font>";
}

if (($start - 50) >= 0)
{
	$previousThree = "<a href=safety_box.php?game=$game&start=$start3>Previous 50</a>";
}
else
{
	$previousThree = "<font color=#cccccc>Previous</font>";
}



ECHO <<<ENDED
</TABLE>


<INPUT TYPE=submit NAME=Submit VALUE="Update" stock></FONT></P></CENTER></form>
<p align=center>$previousThree | $nextThree</p>

ENDED;

print "$closeHTML";
?>

 

Process.php

<?php

/*

Process Add Reply (add_reply.pro.php)

*/
ob_start();
$rank_check = 1;
include "global.inc.php";


$query2 = mysql_query("SELECT * FROM usersitems2 WHERE owner = '$userid' AND game = '$game'");
$num_items = mysql_num_rows($query2);
if ($num_items >= 100)
{
die(header(error("safety_box.php?game=$game", "Sorry $username, but you have $num_items items out already")));
}

$find_items2 = mysql_query("SELECT * FROM safety_box WHERE owner = '$userid' AND game = '$game' ORDER BY item_id");
while ($find_items = mysql_fetch_array($find_items2))
{
$id = $find_items[id];

if ($remove[$id] > 0)
{
	if ($remove[$id] <= $find_items[stock])
	{
		if (($find_items[stock] - $remove[$id]) >= 0)
		{
			mysql_query("UPDATE safety_box SET stock = stock - $remove[$id] WHERE id = '$id' AND owner = '$userid' AND game = '$game'");
		}
		if (($find_items[stock] - $remove[$id]) == 0)
		{
			mysql_query("DELETE FROM safety_box WHERE id = '$id' AND owner = '$userid' AND game = '$game'");
		}

		$findItem3 = fetch("SELECT id,parts FROM items2 WHERE id = '$find_items[item_id]' AND game = '$game'");
		$y = 1;
		while ($y <= $remove[$id])
		{
			mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','$findItem3[id]','$findItem3[parts]','$game')");
			$y++;
		}
	}
}
}

header(error("safety_box.php?game=$game","All commands were executed!"));

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.