Jump to content

Whats the best way to do this?


miracle_potential

Recommended Posts

I have my functions file that has no bugs at all in it but I cant for the life of me work out how to do this, be it common sense or technical know how. But I think I lack both on this one  ;)

 

---EDIT----

I need the script to take the catagory depicted from the URL and search the database (1 Table) for all of the items within that catagory showing its picture its title and a link to its ID, not fussed what it looks like I can jazz it up

-----------

 

 

the current code I have is this --v

 

<?

include("../includes/connect.php");

class getURL {

function getURL(){//VERY simple function to get the catagory from the URL

$cat = $_GET['cat'];
$this->CatagoryCheck($cat);
}

function CatagoryCheck($cat){//checks the catagory specified in the url against an array of the catagories

$back = $HTTP_SERVER_VARS['HTTP_REFERER'];

$catagory_array = array("earings","necklaces","bracelets","anklets","hair accessories","alchemy gothic range","brooches");
if(in_array($cat, $catagory_array) == false){
$catagory = "ERROR _1 INVALID CATAGORY";
$content = "<span class='maintxt'>OOPS! Looks like thats an invalid catagory</span><br /><br /><strong><a class='maintxt' href=".$back.">Back</a></strong>";
$this->error_mailer($cat);
$this->echos($catagory, $content);
	}
		else{
			$this->static_query($cat);
		}
}

function static_query($cat){//if no errors this function simply forwards onto the queries
if(empty($catagory,$content)){
$this->doit($cat);
}
else{
$this->CatagoryCheck($cat);
}
}

function doit($cat){
//THIS IS WHERE I NEED THE HELP 
}

function error_mailer($cat){

$cause = "catagory changed to " . $cat . " in the URL";
$IP=$_SERVER['REMOTE_ADDR'];
$HOST= gethostbyaddr($IP);
$to = "[email protected]";
$subject = "Error with site";
$body = "An error was found, caused by " . $cause . " this action was performed by ". $HOST;
mail($to, $subject, $body);

}

function echos($catagory, $content){//this is the table with the echo'd contents according to previous steps of the class
echo "<table width='100%' border='0' cellspacing='0' cellpadding='0'>
                <tr>
                  <td class='browse'><span class='headers'>". $catagory . "</td>
                </tr>
                <tr>
                  <td><table width='95%' border='0' align='center' cellpadding='0' cellspacing='0'>
                    <tr>
                      <td>". $content . "</td>
                    </tr>
                  </table></td>
                </tr>
                <tr>
                  <td> </td>
                </tr>
              </table>";
}
}

?>

 

If anyone can help me that'd be great :)

 

Also the table structure is --v

 

CREATE TABLE prod_inf (
  ID int(11) NOT NULL auto_increment,
  PRODUCT_ID int(11) NOT NULL,
  DESCRIPTION text NOT NULL,
  CATAGORY text NOT NULL,
  PICTURE_1 text NOT NULL,
  PICTURE_2 text NOT NULL,
  PRICE int(11) NOT NULL,
  POSTAGE mediumint(9) NOT NULL,
  PRIMARY KEY  (ID)
) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;

 

Thanks guys!  ;D

Link to comment
https://forums.phpfreaks.com/topic/102115-whats-the-best-way-to-do-this/
Share on other sites

Ah it worked but thats probably a better way to have it.

 

That wasnt the issue the problem was if you look through the code I need some way of a query passing the results to a function that echos them and its going to be quite a number of rows echo'd so yeah I wasnt sure how to go about it

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.