6 Replies - 1981 Views - Last Post: 06 July 2011 - 08:01 AM

#1 coldrei  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 27-June 11

Google Chrome, Firefox works fine but in IE...

Posted 30 June 2011 - 11:34 PM

Ok. It gives me a headache., I run this code on both Chrome and Firefox but when I test it on IE the search result is blank., totally, not even the echo for errors.

It's only the IE8 browser.

it is search and pagination code. can anyone give me a hint were is the problem? is it my code? or it is only the version of IE?

<?
function search() {
					require("vars.inc.php");
					if (isset($_GET['imageField2'])){
								$set=$_GET['imageField2'];
							
						
							$search=mysql_real_escape_string($_GET['sitesearchkey']);
							$search_param=urlencode($_GET['sitesearchkey']);
							$search_result = "";
							 // Get the search variable from URL
							
							$var = @$search ;
							$trimmed = trim($var); //trim whitespace from the stored variable					
							$_SESSION["trimmed"]=$trimmed;
						
							$tbl_name="members";		//your table name
							// How many adjacent pages should be shown on each side?
							$adjacents = 1;
							
							/* 
							   First get total number of rows in data table. 
							   If you have a WHERE clause in your query, make sure you mirror it here.
							*/
							$query = "SELECT COUNT(*) as num FROM $tbl_name WHERE confirmed='1' AND $field_name LIKE '%".$trimmed."%' ORDER BY $field_name";
							$total_pages = mysql_fetch_array(mysql_query($query));
							$total_pages = $total_pages[num];
							
							//mon2x try
							if ($total_pages == 0){
							
							$noresults = "Sorry, your search:<strong>\" $var\"</strong> returned zero results.";
							}
							/* Setup vars for query. */
							$targetpage = "search.php"; 	//your file name  (the name of this file)
							$limit = 6; 								//how many items to show per page
							$page = $_GET['page'];
							if($page){ 
								$start = ($page - 1) * $limit; 			//first item to display on this page
							}
							else{
								$start = 0;								//if no page var is given, set start to 0
								
							}
							/* Get data. */
							$sql = "SELECT * FROM $tbl_name WHERE $field_name LIKE '%".$trimmed."%' AND confirmed='1' ORDER BY $field_name LIMIT $start, $limit";
							$result = mysql_query($sql);
							
							/* Setup page vars for display. */
							if ($page == 0) $page = 1;					//if no page var is given, default to 1.
							$prev = $page - 1;							//previous page is page - 1
							$next = $page + 1;							//next page is page + 1
							$lastpage = ceil($total_pages/$limit);		//lastpage is = total pages / items per page, rounded up.
							$lpm1 = $lastpage - 1;						//last page minus 1
							
							/* 
								Now we apply our rules and draw the pagination object. 
								We're actually saving the code to a variable in case we want to draw it more than once.
							*/
							$pagination = "";
							if($lastpage > 1)
							{	
								$pagination .= "<div class=\"pagination\">";
								//previous button
								if ($page > 1) 
									$pagination.= "<a href=\"$targetpage?page=$prev&sitesearchkey=$search_param&imageField2=$set\"> previous</a>";
								else
									$pagination.= "<span class=\"disabled\"> previous</span>";	
								
								//pages	
								if ($lastpage < 7 + ($adjacents * 2))	//not enough pages to bother breaking it up
								{	
									for ($counter = 1; $counter <= $lastpage; $counter++)
									{
										if ($counter == $page)
											$pagination.= "<span class=\"current\">$counter</span>";
										else
											$pagination.= "<a href=\"$targetpage?page=$counter&sitesearchkey=$search_param&imageField2=$set\">$counter</a>";					
									}
								}
								elseif($lastpage > 5 + ($adjacents * 2))	//enough pages to hide some
								{
									//close to beginning; only hide later pages
									if($page < 1 + ($adjacents * 2))		
									{
										for ($counter = 1; $counter < 7 + ($adjacents * 2); $counter++)
										{
											if ($counter == $page)
												$pagination.= "<span class=\"current\">$counter</span>";
											else
												$pagination.= "<a href=\"$targetpage?page=$counter&sitesearchkey=$search_param&imageField2=$set\">$counter</a>";					
										}
										$pagination.= "...";
										$pagination.= "<a href=\"$targetpage?page=$lpm1&sitesearchkey=$search_param&imageField2=$set\">$lpm1</a>";
										$pagination.= "<a href=\"$targetpage?page=$lastpage&sitesearchkey=$search_param&imageField2=$set\">$lastpage</a>";		
									}
									//in middle; hide some front and some back
									elseif($lastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2))
									{
										$pagination.= "<a href=\"$targetpage?page=1&sitesearchkey=$search_param&imageField2=$set\">1</a>";
										$pagination.= "<a href=\"$targetpage?page=2&sitesearchkey=$search_param&imageField2=$set\">2</a>";
										$pagination.= "...";
										for ($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++)
										{
		
											if ($counter == $page)
												$pagination.= "<span class=\"current\">$counter</span>";
											else
												$pagination.= "<a href=\"$targetpage?page=$counter&sitesearchkey=$search_param&imageField2=$set\">$counter</a>";					
										}
										$pagination.= "...";
										$pagination.= "<a href=\"$targetpage?page=$lpm1&sitesearchkey=$search_param&imageField2=$set\">$lpm1</a>";
										$pagination.= "<a href=\"$targetpage?page=$lastpage&sitesearchkey=$search_param&imageField2=$set\">$lastpage</a>";		
									}
									//close to end; only hide early pages
									else 
									{
										$pagination.= "<a href=\"$targetpage?page=1&sitesearchkey=$search_param&imageField2=$set\">1</a>";
										$pagination.= "<a href=\"$targetpage?page=2&sitesearchkey=$search_param&imageField2=$set\">2</a>";
										$pagination.= "...";
										for ($counter = $lastpage - (2 + ($adjacents * 2)); $counter <= $lastpage; $counter++)
										{
											if ($counter == $page)
												$pagination.= "<span class=\"current\">$counter</span>";
											else
												$pagination.= "<a href=\"$targetpage?page=$counter&sitesearchkey=$search_param&imageField2=$set\">$counter</a>";					
										}
									
									
									
									}
								}
								
								//next button
								if ($page < $counter - 1) 
									$pagination.= "<a href=\"$targetpage?page=$next&sitesearchkey=$search_param&imageField2=$set\">next </a>";
								else
									$pagination.= "<span class=\"disabled\">next </span>";
								$pagination.= "</div>\n";		
							}
		?>
		
			<?php
				
				
				$search_result = "";
				
				$search_result .= " <table width='100%'>
				
												
												<tr>";
				while($row = mysql_fetch_array($result))
				{
					$id = $row["id"];
									  $field1 = $row["field1"];
									  $field2 = $row["field2"];
									  $field3 = $row["field3"];
									  $field4 = $row["field4"];
									
									  $search_result .= "<form action='client/form_user_profile.php' method='get'>
														
														<td>
														
														<table width='100%' cellspacing='2' cellpadding='2'>
														
														<tr>
														<td width='35%'><center>
														<a href='http://www.example.php?company_id=$id&view=View' class='b' target='_blank'  />
														<img src='http://example/" . $field1 . "' height='92' width='92' />
														</a>
														</center></td>
														
														<td width='65%' valign='top'><span class='inside_sub_body_red'>
														<a href='http://example.php?company_id=$id&view=View' class='b' target='_blank'  />
														" . $field2 . "
														</a>
														</span>
														<br />
														" . $field3 . "<br />
														" . $accepted_country[$field4] . "<br />												
														<input type='hidden' name='company_id' value='" . $id . "'>
														</td>
														</tr>
														
														</table>
														
														</td>";
									  
														$table = $table + 1;
														
														if ($table=='2'){
									 $search_result .= "</tr><tr>";	
															$table="0";
															}
									 $search_result .= "</form>" ;
				}
				$search_result .= "</table>";
				 $search_result .= "<br />";
		echo $noresults;
		echo $search_result;
							
					}

	?>

<?=$pagination?>



Is This A Good Question/Topic? 0
  • +

Replies To: Google Chrome, Firefox works fine but in IE...

#2 creativecoding  Icon User is offline

  • Hash != Encryption
  • member icon


Reputation: 927
  • View blog
  • Posts: 3,209
  • Joined: 19-January 10

Re: Google Chrome, Firefox works fine but in IE...

Posted 01 July 2011 - 01:28 AM

It's a problem with the browser, not PHP. Your gonna have to ask somewhere else perhaps.
Was This Post Helpful? 0
  • +
  • -

#3 satis  Icon User is offline

  • D.I.C Head

Reputation: 82
  • View blog
  • Posts: 231
  • Joined: 26-May 11

Re: Google Chrome, Firefox works fine but in IE...

Posted 01 July 2011 - 05:24 AM

Have you tried to view source in IE8? I'm not entirely sure what's missing in the IE8 display, but PHP code is PHP code... it doesn't matter what browser you're using. Chances are it's getting exactly the same results, but some quirk is causing it not to display properly.

I've made mistakes with HTML in the past where I forgot to close a tag properly. Firefox and other browsers basically ignored my mistake, while IE8 faithfully screwed up all my HTML. I thought it was an IE8 problem, but after viewing source in IE8, I realized I'd just made a stupid mistake.
Was This Post Helpful? 0
  • +
  • -

#4 codeprada  Icon User is offline

  • Changed Man With Different Priorities
  • member icon

Reputation: 948
  • View blog
  • Posts: 2,357
  • Joined: 15-February 11

Re: Google Chrome, Firefox works fine but in IE...

Posted 01 July 2011 - 05:27 AM

Since you're already here in PHP might as well we address some PHP related problems.
Refrain from using short tags
<? 
//code
?>

The PHP parser will confuse that with
<?xml version...


It's best to take the time and type that extra 3 characters
<?php
//code
?>


Your problem is HTML & CSS related but just out of curiosity what do you see when you view the page's source in IE? Code or nothing still? Do you have the proper HTML layout?
<!DOCTYPE html>
<html>
	<head>
		<!-- CSS, Title, Scripts -->
	</head>
	<body>
		<!-- Search Results Here -->
	</body>
</html>


Perhaps IE isn't as lenient as Firefox and Chrome and requires the proper layout while the latter will automatically place your content in the body tags.

This post has been edited by codeprada: 01 July 2011 - 05:28 AM

Was This Post Helpful? 1
  • +
  • -

#5 Jstall  Icon User is offline

  • Lurker
  • member icon

Reputation: 434
  • View blog
  • Posts: 1,042
  • Joined: 08-March 09

Re: Google Chrome, Firefox works fine but in IE...

Posted 01 July 2011 - 06:42 AM

I agree your problem is malformed XHTML.That code is pretty messy and it would be easy enough to make the mistake of having unclosed elements and such.

Also, I believe when nesting forms in tables the form in it's entirety has to be in one td element. I believe it is more common to put tables inside forms.
Was This Post Helpful? 0
  • +
  • -

#6 CTphpnwb  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 3039
  • View blog
  • Posts: 10,618
  • Joined: 08-August 08

Re: Google Chrome, Firefox works fine but in IE...

Posted 01 July 2011 - 08:21 AM

View Postcoldrei, on 01 July 2011 - 02:34 AM, said:

Ok. It gives me a headache., I run this code on both Chrome and Firefox but when I test it on IE the search result is blank., totally, not even the echo for errors.

No, it runs on your server. The results are processed on the browser, and those results do not include PHP. It may seem like I'm nitpicking, but this is an important point that you're not getting and as long as you don't it's going to cause problems for you. Memorize and understand the order in which things occur:
  • User takes an action.
  • Browser sends a request to server.
  • Server runs PHP script.
  • PHP script sends output to browser.
  • Browser renders information.
  • User sees information.
  • Repeat.


Moving to HTML...
Was This Post Helpful? 0
  • +
  • -

#7 Caradoc Collins  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 30-June 11

Re: Google Chrome, Firefox works fine but in IE...

Posted 06 July 2011 - 08:01 AM

Hi there,

A general tip: Create a copy of your file, comment everything in your HTML code until you just load the applet, try it in IE6/7 and uncomment your code until the error reappears. This should give you a good idea what's breaking your applet if your "uncomment steps" are small enough (take care with dependencies though, to not introduce new bugs).

If you can't find the problem please upload the last working and the broken version to your webspace.

Hope that helps, sorry if not. You can PM me if required.
Kind regards,
Caradoc Collins.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1