Hello Friends,
I have writtin for loop to display query result, in order to build the page dynamically.
It is working okay on IE 5.5, but not on Natscape Nevigator 6.2.
Does any one have idea about it?
Thanks.
Bharti.
Hello Friends,
I have writtin for loop to display query result, in order to build the page dynamically.
It is working okay on IE 5.5, but not on Natscape Nevigator 6.2.
Does any one have idea about it?
Thanks.
Bharti.
sorry for my previous msg. about "for loop doesn't work in NN"...
I could just figure out the why it is nor working in NN... actually, it has raised another quesion.
Following is the code :
$result = mysql_query($modStmt, $link);
print($result);
// I guess, above code is being understood by NN and did print something like : Resource id #2
$num_row = mysql_num_rows($result);
print($num_row);
// I guess, above code is not understood by NN and did print 0 rows, where as IE printed 9 rows .
for ($i=0; $i < $num_row ; $i++){
$row = mysql_fetch_array($result);
printf("<tr>");
print("<td width=17%> $row[mod_id] </td>");
}
Could any one advice me please? Thanks.
Okay, I think maybe you're misunderstanding how php works. It's not going to be browser specific as the code is interpretted by the server not the browser. If there is an output problem, it probably has something to do w/ differences in how HTML is displayed by the different browsers. Take a look at the source of the resulting page and see if you can find where the problem is in the output.
Yes friend, I knw that the PHP is the server side scripting.
So, could you pls. let me know that when executed following statment on the IE it returns me 9 rows ( that is correct), but when run on NN it returns 0 rows.
$result = mysql_query($modStmt, $link);
$num_row = mysql_num_rows($result);
for ($i=0; $i < $num_row ; $i++){
$row = mysql_fetch_array($result);
printf("<tr>");
print("<td width=17%> $row[mod_id] </td>");
}
are you SURE that php code will write a valid html code? i dont think so...
netscape does not shows incomplete or wrong html tables.
try:
<table>
<?php
for (...number of lines...) {
echo '<tr>';
for (...number of columns){
echo '<td>'.data.'</td>';
}
echo '</tr>';
}
?>
</table>
Yes, as icaro has pointed out, the HTML generated is less than ideal. Netscape tends to be much more finicky than wind-blows IE about this; the later the netscrape version, the more finicky.
Netscape is way too finicky and IE is the superior product. Either way you want to output/write valid code but it sure is nice if you leave a tag open that IE will close it for you.
The code icaro is showing is exactly what you need to keep in mind when drawing tables based upon output from a data base. You need to put your table tags outside your loop and the code needs to know when to move to a new row. You can do it all in one while loop with a modulo division to change rows.
if ($cellcount % 3 == 0) { echo "</tr><tr>\n";}
Hope this helps,
B
Hello Friends,
I did check for tags, if there is any unclosed. However, that is in order.
My problem is occurs before drawing the table actually.
some excerpt from the code :
function bld_tbl($tblName, $semVal, $chbName, $ruleMin, $ruleMax){
global $sess_prog;
global $link;
global $sess_part;
$modStmt = "select mod_id, title, mod_wt from modid_titles_2002_2003 where prog = \"$sess_prog\" and part = \"$sess_part\" and semester = \"$semVal\" ";
$result = mysql_query($modStmt, $link);
$num_row = mysql_num_rows($result);
print($num_row); // this is returned as 0 rows in NN
.... here goes the table code.
} // end of function bld_tbl
Well, I have double checked for any unclosed tags, but there is none.
As I mentioned that the actual problem occuers before the code of table. i.e. the statement, $num_row = mysql_num_rows($result); is returing the 0 (zero) rows when run from NN and shows 9 rows when run from IE !!!
The table will be drawn only if $num_row > 0. As it has 0 rows, it is not pringing for me. So, I don't think that the problem is coz of tag.
Can someone advice please? Thanks a lot.
Just for the heck of it, skip the table crap-ola for a moment and try something like this. We'll make it pretty later, let's make it work first:
function bld_tbl($tblName, $semVal, $chbName, $ruleMin, $ruleMax){
global $sess_prog;
global $link;
global $sess_part;
// make sure all the values really are getting to the function and they are what you think they are.
// Sure this is anal, but it can be easily commented out, since the error described *shouldn't* be happening:
echo $tblName . ' ' . $semVal . ' ' . $chbName ' ' . $ruleMin . ' ' . $ruleMax . ' ' . $sess_prog . ' ' . $link . ' ' . $sess_part;
// here's the query:
$modStmt = "select mod_id, title, mod_wt from modid_titles_2002_2003 where prog = \"$sess_prog\" and part = \"$sess_part\" and semester = \"$semVal\" ";
// try and get a result handle:
$result = mysql_query($modStmt, $link);
// Check to see if you *did* get a result:
if(!$result) {
echo 'Query: ' . $modStmt . ' failed.';
// No sense in continuing if the query failed:
return;
}
// Since there's a difference between a query 'failing' and a query not having any rows
// check to make sure there are rows in the result set:
if(!mysql_num_rows($result)) {
echo 'Query: ' . $modStmt . ' returned no rows.';
return;
}
// If we reach this part of the function we *must* have a result handle which has rows of data.
// We'll use fetch array, and specify MYSQL_ASSOC so we don't waste system resources unnecessarily:
while($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
// for now, print a <p> for each row, turn it into tables when this much is functioning consistently on *all* yer browsers:
printf("<p>%s, %s, %s</p>",$row['mod_id'], $row['title'], $row['mod_wt']);
}
// Clean up your result set:
mysql_free_result($result);
}
Just fer laughs, dump the cache on both yer browsers... No, I don't suspect that that should change anything. But amuse me, please...
I gotta run off to see the very lovely msmufin now, drop a PM and lemme know if this behaves consistently all around...
Originally posted by bakertrg
Netscape is way too finicky and IE is the superior product. Either way you want to output/write valid code but it sure is nice if you leave a tag open that IE will close it for you.
Funny, I'd say that Netscape was superior for exactly the same reason. It helps cuts down on the amount of bad HTML out there.
How many people write pages that break on anything other than IE, because they used IE to view them and IE was being "nice"?