0

I'm new to php, as my question will probably clearly show.

I'm writing a simple program to track bills, and one thing I'm trying to do is include a "Find text that contains" box that will highlight certain fields in my table that match the search. The code I've written and thought should work... broke it. Completely.

Any help at all figuring out where I've gone wrong would greatly greatly appreciated. The pertinent block of code is:

$action = $_POST['action'];

	while ($action == 'Submit') {
	
		$myarray = array();
		$myelement = $item_value."*".$amount_value."*\n";
		array_push($myarray, $myelement);
	
		$array_counter = $i - 1;  //To make sure when get element 0 in the array!
	
		list($item_value, $amount_value) = explode("*", $myelement[$array_counter]);
		
		$pos = strpos($myarray, $targetstring)
		
		
		if($pos !== $targetstring) {
		
			print "<td><input type=text name=$item_name value=$item_value></td>";
			print "<td><input type=text name=$amount_name value=$amount_value></td>";
	
			else {
				print "<td><input type=text name=$item_name value=$item_value style=\"background-color: Yellow;\"></td>\n";
				print "<td><input type=text name=$amount_name value=$amount_value style=\"background-color: Yellow;\"></td>\n";
			}
		}
	}
2
Contributors
1
Reply
3
Views
6 Years
Discussion Span
Last Post by aquilax
0

Can't see what's the point of using arrays here:

$action = $_POST['action'];
if ($action == 'Submit') {
  if(strpos($item_value."*".$amount_value, $targetstring) !== FALSE) {
    print "<td><input type=text name=$item_name value=$item_value></td>";
    print "<td><input type=text name=$amount_name value=$amount_value></td>";
  } else {
    print "<td><input type=text name=$item_name value=$item_value style=\"background-color: Yellow;\"></td>\n";
    print "<td><input type=text name=$amount_name value=$amount_value style=\"background-color: Yellow;\"></td>\n";
  }
}

Edited by aquilax: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.