I have a code that needs to read in a file and has a parameter file. I need to know how to put in <=,<,=,>=,> operators that will be in my parameter file.

I beleive that it needs to go in this line:
$search=explode(':',strtoupper($params[0]));
but not sure if it will look like this
$search=explode('<','<=','>','>=','=',strtoupper($params[0]));

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"  
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
<html xmlns="http://www.w3.org/1999/xhtml">  
<head>  
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  
<title>Untitled Document</title>  
</head> 
  
<body> 

<?php  


// check to see if file uploaded, using the super-global array $_FILES  
if (isset($_FILES['UploadedFile']['tmp_name']))  
{
	# $_FILES['fieldname']['name'] gives the uploaded file name
	print ("<p>");  
	$filename = dirname(__FILE__).'/'.$_FILES['UploadedFile']['name']; 
	move_uploaded_file($_FILES['UploadedFile']['tmp_name'], $filename);
	$OUTFILE = fopen($filename, 'r') or die("Can't open $filename for read");

	//read the entire file into an array
	$params=file('parameters.txt');

	//after this $type will have "SPORT"
	$search=explode(':',strtoupper($params[0]));
	$searchColumn=trim($search[0]);
	$searchValue=trim($search[1]);

	//after this $columns[0] will have "MODEL" && $columns[1] will have "PRICE"
	$columns=explode("~",strtoupper(trim($params[1])));

	//read the first line of the csv
	$data = fgetcsv($OUTFILE,1000, "~");

	//now find which column corresponds to "TYPE"
	$typeIndex=array_search($searchColumn, $data);

	//now find out the column index for each of the columns specified in parameters.txt
	foreach($columns as $i=>$v)
	{
		if(FALSE===($columns[$i]=array_search($v, $data)) )
		{
			echo ("Column $v does not seem to exist");
			unset($columns[$i]);
		}
	}

	echo('<table>'); 
	do{
		

		//make sure that the type value of the current $data row matches what
		//was provided in $type (in parameters.txt)
		if( strtoupper($data[$typeIndex]) == strtoupper($searchValue) )
		{	
			echo('<tr>');
			//now iterate only over the set of requested columns
			foreach($columns as $dataIndex){
				echo("\t<td>{$data[$dataIndex]}</td>\r\n"); 
			}
			echo('</tr>'); 
		}
		
	}while (($data = fgetcsv($OUTFILE,1000, "~")) !== FALSE);  
	echo('</table>');           
	fclose($OUTFILE); 
}
?>   

   <form enctype="multipart/form-data"   action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">  
   <!-- <input type="hidden" name="MAX_FILE_SIZE" value=" " />   -->
   <input name="UploadedFile" type="file" />  
   <input type="submit" value="UPLOAD" />  

         <h2> Soucre Code File</h2>       
        <p>  
        <?php        
            show_source(__FILE__);   
            ?>   
        </p> 
   
</body>  
</html>

the file i will be reading in

MAKE~MODEL~TYPE~PRICE
Toyota~Camry~Sedan~18000
Toyota~Tacoma~Truck~19000
Ford~Mustang~Sport~21000
Chevrolet~Corvette~Sport~48000
Ford~F150~Truck~25000
Toyota~Highlander~SUV~35000

My Parameter file

Price<3500
MAKE~MODEL~PRICE

any help with this?

What exactly are you trying to do ? … You are trying to read a file and parse the content of it ? If so what are the parsing rules and in what type do you wish the output ?

I am just trying to do a restriction like getting the price if it less than 20000. And i am not sure what you mean parsing rules and what type of output do i want

Ok my friend lets take it step by step . You don’t end form in the code (you don’t have </form>) . PHP_SELF is not a URL to post to …it is where the php program stands in server (see http://php.net/manual/en/reserved.variables.server.php) … If you need to find where are you just tell me and I will make you a function for that (although my framework is providing it).

In lines 71-75 i really dont need i just have that in from past times. All i need is in line 27 i need to change what the code is looking for to either <,>,=,<=,>=.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.