views:

357

answers:

6

I am trying to apply css to php code. But it not working well in Internet Explorer, But working fine in firefox

Code :

   echo '<div class="resultno">';
   echo "<td>" . $row['stu_id'] . "</td>"." ";
   echo '</div>';
   echo "<td>" . $row['Name'] . "</td><br>". " ";
   echo "<br>";

And it looks like --> http://www.flickr.com/photos/41695354@N08/3957144073/

Any suggestions please help

A: 

not sure about your use of single quotes, try:

echo "<div class=\"resultno\">";
marauder
No, the single quotes are fine.
jimyi
Then Whats the problem. Please anyone say
Rajasekar
The problem was highlighted in buti-oxa's answer. A td must go inside a tr, and a tr must go inside a table -- you cannot put a td directly inside a div.
bigmattyh
When i removed td, its also not working @bigmattyh
Rajasekar
A: 

IE has a lot of problems with its interpretation of CSS. See:

www.haslayout.net

http://www.quirksmode.org/

http://www.positioniseverything.net/explorer.html

...and a variety of others, try to find the specific issue you are experiencing, also try the CSS using straight HTML without any PHP code; you can use a test page like:

http://www.jmarshall.com/easy/html/testbed.html

RMorrisey
+12  A: 

You should not have TD directly inside DIV, it's invalid HTML. TD is supposed to sit inside TR inside TABLE.

When you omit necessary element like that, browser tries to guess what you mean, and who knows what that leads to.

Answering additional question: Guessing what you are trying to do, I'd say that you should get rid of the div and apply the resultno class directly to the TD.

buti-oxa
+3  A: 

The problem is that the HTML code is completely broken.

You are putting elements inside the table but outside the table cells. This is not allowed, and different browsers have different ways of interpreting the code to try to make sense of it. That is why you are getting so different results.

A table element contains table rows (tr), which contain table cells (th,td). Inside the table cells you can put other content, but not anywhere else in the table.

Guffa
So what i have to do. Please help
Rajasekar
Well, first you have to decide if you are going to use a table or not. From the little code that I have seen I can't even tell what kind of solution you are trying to use...
Guffa
+1  A: 

You need something more like this (as Guffa and buti-oxa said):

   echo '<div class="resultno">';
   echo "<tr>";
   echo "<td>" . $row['stu_id'] . "</td>"." ";
   echo "</tr>"." ";
   echo '</div>';
   echo "<td>" . $row['Name'] . "</td><br>". " ";
   echo "<br>";

Don't generally program in this language so not 100% if it's correct, but that ought to do it.

RCIX
That's still just as broken... It should either be a table with rows and cells, or no table elements at all.
Guffa
but it looks like it has them. it has <tr> and <td> inside, ???
RCIX
A: 

I would recommend just using DIV elements instead.

Also, to save on single/double quotation complications, you can just break out of PHP when you want, and break back into it to echo the variables. This gives your code much more readability and saves on all the echoes. Also ideal if you are using a program that highlights different languages like PHPedit or something similar.

i.e.

CSS:

<style>
  .stuID { float:left; width: 150px; }
  .studName { float:left; width: 300px; } 
</style>

HTML & PHP:

<?php foreach($array as $row): ?>

    <div class="resultno">
      <div class="stuID"><?=$row['stu_id']?></div>
      <div class="stuName"><?=$row['Name']?></div>
    </div>

<?php endforeach; ?>

Im guessing at how you want the results to appear on screen, but you get the idea of where I am going with this. Hope I'm not barking up the wrong tree!

Tisch