Jump to content

Two nearly identical pages two very different results


TheChaosFactor

Recommended Posts

Ok, so I have grabbed a free template and attempted to put a dynamic table into one of the div's.  I've got it to work on on my index.php, but I copied and pasted the entire code into member2.php and only changed the query and altered the table just a little bit  For some reason though my table doesn't show up on the member2.php even though 90% of the code is the same.

 

Here are the pages and codes...

 

http://www.royalfamilyhosting.com/test/index.php

 

<div id="layoutBodyContent">
        	<h1>Aces Guild Donations Page </h1>
            <h2>Are you on top of your game? WE are!</h2>

           <?PHP


require_once('./mylib.php');
$rank = 1;
$olddate = strtotime(date("Y-m-d"));
$newdate;
$datecounter = 1;

//connects to db
dbconnect();


$query="SELECT name, date, SUM(amount) as total_money, SUM(bricks) as total_bricks FROM Aces_Donations GROUP BY Name ORDER BY total_money DESC, total_bricks DESC";
$result=mysql_query($query);


//Opens the table
echo "<table border = '3' width = 40% bgcolor=#A85045><caption><center>30 Day Rankings".'</center></caption>';

//Loop to run until eof

while($row = mysql_fetch_array($result)){

//turns date into a comparable string
$newdate = strtotime($row['date']);

/*checks to see if date of new record matches date of previous record. If dates dont match the table is closed and a new table is opened for the new date. Rank is reset to reflect rankings for each specific date*/
if($newdate !== $olddate){
	$olddate = $newdate;
	$datetracker++;
	if($datetracker == 30){

	echo "<center><tr><td alignment = 'center'>".$rank."</td>	<td alignment = 'center'>".$row['name']. "</td><td 	alignment = 'center'>". $row['total_money']."</td><td alignment= 'center'>".$row['total_bricks']."</tr></table></center>";
	break;
	}
}
echo "<center><tr><td alignment = 'center'>".$rank."</td>	<td alignment = 'center'>".$row['name']. "</td><td 	alignment = 'center'>". $row['total_money']."</td><td alignment= 'center'>".$row['total_bricks'].'</td></tr>';

echo '<br />';
$rank++;

}
echo '</table>';

?>


		<br /><br /></p>
        </div>

 

 

http://www.royalfamilyhosting.com/test/member2.php?member=Zneve08

 

<div id="layoutBodyContent">
        	<h1>Aces Guild Donations Page </h1>
            <h2>Are you on top of your game? WE are!</h2>

           <?PHP


require_once('./mylib.php');
$membername = $_GET['member'];
$rank = 1;
$olddate = strtotime(date("Y-m-d"));
$newdate;
$datecounter = 1;

//connects to db
dbconnect();


$query = sprintf("SELECT * FROM `Aces_Donations` WHERE `name` = '%s'",
$membername);

//sets the results to a variable
$result = mysql_query($query) or die(mysql_error());

//opens table, sets width, color, border and headers

echo '<table bgcolor=#A85045 border = "3" width = 40%>';
echo "<tr><th alignment = 'center'>Member</th>
<th alignment = 'center'>Amount</th><th alignment = 'center'>Date</th></tr>";

while($row = mysql_fetch_array($result)){
echo "<center><tr><td alignment = 'center'>".$row['name']. "</td><td alignment = 'center'>". $row['amount']."</td><td alignment 	= 'center'>".$row['date']."</td></tr></center>";
var_dump ($row['name']);
var_dump ($row['amount']);
echo "<br />";
}
echo '</center></table>';

?>


		<br /><br /></p>
        </div>

 

I'm dying here and would love even shot in the dark at this point.  The php code on member2.php works just fine when executed on its own page, so I don't really understand how this is happening.  I put the var_dump in there just to make sure the data was being retrieved from the database, but the table should be positioned where the var_dump displays on the page

Link to comment
Share on other sites

It is echoing the data; it's present in the html source. This is an html validity issue. alignment is not a valid attribute, and you don't use <center> tags within the table structure like that. Try this.

 

echo "<table bgcolor=\"#A85045\" border=\"3\" width=\"40%\">\n<tr>\n<th align=\"center\">Member</th>\n
<th align=\"center\">Amount</th>\n<th align=\"center\">Date</th>\n</tr>\n";
while($row = mysql_fetch_array($result)){
echo "<tr>\n<td align=\"center\">{$row['name']}</td>\n<td align=\"center\">{$row['amount']}</td>\n<td align=\"center\">{$row['date']}</td>\n</tr>\n";
//var_dump ($row['name']);
//var_dump ($row['amount']);
}
echo "</table>";

Link to comment
Share on other sites

Still got nothing on the page, but it's still showing up in the source code...

 

Also, if you go to just http:www.royalfamilyhosting.com/test/member2.php    and then add on "?member=Zneve08"  and and go to the same page with some info passed, you can see the div container get bigger, so it knows there's something in there.

 

I maybe should have mentioned that the other one is positioned with css like so:

 

table a, table, tbody, tfoot, tr, th, td, table caption {
font-family: Verdana, arial, helvetica, sans-serif;
background:#262b38;
color:#fff;
text-align:left;
font-size:12px;
position:relative;
bottom: xxxpx;
left:xxxpx;

}

 

I've tried adjusting the bottom and left values as well as removing those parameters and I still get no change at all...

Link to comment
Share on other sites

Still got nothing on the page, but it's still showing up in the source code...

 

Also, if you go to just http:www.royalfamilyhosting.com/test/member2.php    and then add on "?member=Zneve08"  and and go to the same page with some info passed, you can see the div container get bigger, so it knows there's something in there.

 

I maybe should have mentioned that the other one is positioned with css like so:

 

table a, table, tbody, tfoot, tr, th, td, table caption {
font-family: Verdana, arial, helvetica, sans-serif;
background:#262b38;
color:#fff;
text-align:left;
font-size:12px;
position:relative;
bottom: xxxpx;
left:xxxpx;

}

 

I've tried adjusting the bottom and left values as well as removing those parameters and I still get no change at all...

 

try just changing the 'bottom:xxxpx;' to 'bottom:0px;' it worked for me (in Firefox, IE looks bad no matter which page). The reason it wasn't displaying is that 325px makes the table go outside of the div#layoutBodyContent element, which makes it disappear. Anyway, another thing I notices is that above the 'table a, table, tbody, tfoot, tr, th, td, table caption' are

 

#tbldisplay table a, table, tbody, tfoot, tr, th, td, table caption {...}

#tbldisplayall table a, table, tbody, tfoot, tr, th, td, table caption {...}

#tbldisplay3 table a, table, tbody, tfoot, tr, th, td, table caption {...}

 

The ', table,' in all of those parts are causing the table to be changed 4 times. So the bottom (and such) for the table is being set to 375 to 500 to 375 and finally to 325.

 

Also, I would would definitely do what Pikachu2000 said, alignment is not a valid attribute, etc. Fixing this would probably fix the ugly tables I see using IE on the pages.

Link to comment
Share on other sites

try just changing the 'bottom:xxxpx;' to 'bottom:0px;' it worked for me (in Firefox, IE looks bad no matter which page). The reason it wasn't displaying is that 325px makes the table go outside of the div#layoutBodyContent element, which makes it disappear. Anyway, another thing I notices is that above the 'table a, table, tbody, tfoot, tr, th, td, table caption' are

 

#tbldisplay table a, table, tbody, tfoot, tr, th, td, table caption {...}

#tbldisplayall table a, table, tbody, tfoot, tr, th, td, table caption {...}

#tbldisplay3 table a, table, tbody, tfoot, tr, th, td, table caption {...}

 

The ', table,' in all of those parts are causing the table to be changed 4 times. So the bottom (and such) for the table is being set to 375 to 500 to 375 and finally to 325.

 

Also, I would would definitely do what Pikachu2000 said, alignment is not a valid attribute, etc. Fixing this would probably fix the ugly tables I see using IE on the pages.

 

Ok, you nailed it.  Changing it to "bottom:0px;" did it for member2.php but it messed up my index.php because that 325px was what put the table where it should be on that page.  I can live with multiple stylesheets though.

 

Thank both you guys for all your help.  I really appreciate it.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.