Aligning Data in Tables to Top

Hi There,

I am trying to get some data in a table to align to the top of another table, so a table within a table, is there a way in CSS to make this happen? Here is an example of the problem I am having, the table on the left is sagging to far.

http://www.cnghl.biz/cnghldb/cnghlplayerinfo.php?PlayerID=810

Well, yes you can do this in CSS. To do that, you would need to use nested

tags.
You would align the two inside tags to the top of the outside tag. If you want to try that
I can give you some links to sites that explain this.

BUT, since you already have the data inside of a table, you should just use tables.

Simply create one large table and place the two tables that are columns inside that one.

Something, roughly, llike:

Data in your column #1 for the search stuff Your table rows for the second column #2

I think this would be easier as you already have it mostly in place. Just have to add a little more…

BUT, if you want to try it in CSS, let us know…

Thanks for your help, I tried to format it in CSS using div tags, but I immediately get a PHP error when I put a little php in, can you see why I am getting this error?

I get the following error “You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘ORDER BY Players.LastName’ at line 12”

But it works fine when I do it with tables instead of div tags.

[php]<?php
// Connects to your Database
mysql_connect("", “”, “”) or die(mysql_error());
mysql_select_db("") or die(mysql_error());

//Get PlayerID from URL
$iPlayerID = $_GET[“PlayerID”];
$iNationID = $_GET[“NationID”];

$oPlayerInfo = mysql_query("
SELECT Players.PlayerID, Players.FirstName, Players.LastName, Players.Position, Players.Height, Players.Weight, Players.DOB, CNGHLTeams.CNGHLRights, NHLTeams.Team, Players.CNDraftYR, DraftTeam.DraftID, Players.CNDraftPOS, Countries.Nation, Players.NationID, DraftTeam.DrTeam
FROM Players
Left JOIN CNGHLTeams
ON Players.CNGHLID=CNGHLTeams.CNGHLID
Left JOIN NHLTeams
ON Players.TeamsID=NHLTeams.TeamID
Left JOIN Countries
ON Players.NationID=Countries.NationID
Left JOIN DraftTeam
ON Players.DraftID=DraftTeam.DraftID
WHERE Players.PlayerID=$iPlayerID
ORDER BY Players.LastName;
") or die(mysql_error());

while($row = mysql_fetch_array($oPlayerInfo))

ECHO “”;
ECHO “

”;
ECHO “
”;
ECHO “

”.$row[‘FirstName’]." “.$row[‘LastName’].”

";
ECHO “
”;
ECHO “
”;
ECHO “”;
?>[/php]

On line 22 remove the ending “;”
On line 25 you start a WHILE loop. loops need {some code} to loop thru.
So, you do not want it there as you would place each time. That section should be like:

ECHO “”;
ECHO “

”;
ECHO “
”;
while($row = mysql_fetch_array($oPlayerInfo)) {
ECHO “

”.$row[‘FirstName’]." “.$row[‘LastName’].”


";
}
ECHO “
”;
ECHO “
”;
ECHO “”;
?>

Note: this would loop thru the names and display them one per line. (I added the
)
But, if you are using the DIV’s to mark each one as a separate entity, you would need it this way:

ECHO “”;
ECHO “

”;
while($row = mysql_fetch_array($oPlayerInfo)) {
ECHO “
”;
ECHO “

”.$row[‘FirstName’]." “.$row[‘LastName’].”

";
ECHO “
”;
}
ECHO “
”;
ECHO “”;
?>
(This would depend on how you have your CSS set up for the class “nametitle”…)

Hope that helps!

Thanks again for your help, I made the changes to the script and I still get the error, I don’t understand why it won’t work, the code works fine when I do it with tables.

[php]

Untitled Document <?php // Connects to your Database mysql_connect("", "", "") or die(mysql_error()); mysql_select_db("") or die(mysql_error()); //Get PlayerID from URL $iPlayerID = $_GET["PlayerID"]; $iNationID = $_GET["NationID"]; $oPlayerInfo = mysql_query(" SELECT Players.PlayerID, Players.FirstName, Players.LastName, Players.Position, Players.Height, Players.Weight, Players.DOB, CNGHLTeams.CNGHLRights, NHLTeams.Team, Players.CNDraftYR, DraftTeam.DraftID, Players.CNDraftPOS, Countries.Nation, Players.NationID, DraftTeam.DrTeam FROM Players Left JOIN CNGHLTeams ON Players.CNGHLID=CNGHLTeams.CNGHLID Left JOIN NHLTeams ON Players.TeamsID=NHLTeams.TeamID Left JOIN Countries ON Players.NationID=Countries.NationID Left JOIN DraftTeam ON Players.DraftID=DraftTeam.DraftID WHERE Players.PlayerID=$iPlayerID ORDER BY Players.LastName ") or die(mysql_error()); ECHO ""; ECHO ""; ECHO "
"; while($row = mysql_fetch_array($oPlayerInfo)) { ECHO "
"; ECHO "

".$row['FirstName']." ".$row['LastName']."

"; ECHO "
"; } ECHO "
"; ECHO ""; ?> [/php]

Oh, now remove the ECHO line, you already sent out the tag before the PHP.

Done, but I still get the error.

On lines 11 and 12, did you put in your connection info? It is blank where you posted it.
Using it on my server, it gives me an error “Not connected to database”.

What is the error you get? Does it connect to the DB?

It seems to connect to the db, I put the login information for the server I have on Godaddy. the error I am getting is “You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘ORDER BY Players.LastName’ at line 12”

So, let’s look at the query itself, too.
Change the query from this:
$oPlayerInfo = mysql_query("
SELECT Players.PlayerID, Players.FirstName, Players.LastName, Players.Position, Players.Height, Players.Weight, Players.DOB, CNGHLTeams.CNGHLRights, NHLTeams.Team, Players.CNDraftYR, DraftTeam.DraftID, Players.CNDraftPOS, Countries.Nation, Players.NationID, DraftTeam.DrTeam
FROM Players
Left JOIN CNGHLTeams
ON Players.CNGHLID=CNGHLTeams.CNGHLID
Left JOIN NHLTeams
ON Players.TeamsID=NHLTeams.TeamID
Left JOIN Countries
ON Players.NationID=Countries.NationID
Left JOIN DraftTeam
ON Players.DraftID=DraftTeam.DraftID
WHERE Players.PlayerID=$iPlayerID
ORDER BY Players.LastName
") or die(mysql_error());

To this:
[php]
$query ="
SELECT Players.PlayerID, Players.FirstName, Players.LastName, Players.Position, Players.Height, Players.Weight, Players.DOB, CNGHLTeams.CNGHLRights, NHLTeams.Team, Players.CNDraftYR, DraftTeam.DraftID, Players.CNDraftPOS, Countries.Nation, Players.NationID, DraftTeam.DrTeam
FROM Players
Left JOIN CNGHLTeams
ON Players.CNGHLID=CNGHLTeams.CNGHLID
Left JOIN NHLTeams
ON Players.TeamsID=NHLTeams.TeamID
Left JOIN Countries
ON Players.NationID=Countries.NationID
Left JOIN DraftTeam
ON Players.DraftID=DraftTeam.DraftID
WHERE Players.PlayerID=$iPlayerID
ORDER BY Players.LastName";
die($query);
$oPlayerInfo = mysql_query($query) or die(mysql_error());
[/php]
What this will do is show you what the query really looks like. The variable $iPlayerID is in question !
This should show you what it looks like. And, you can just remove the DIE() line after we fix it up…

Thanks again, I made the change and now I get the following on my screen.

“SELECT Players.PlayerID, Players.FirstName, Players.LastName, Players.Position, Players.Height, Players.Weight, Players.DOB, CNGHLTeams.CNGHLRights, NHLTeams.Team, Players.CNDraftYR, DraftTeam.DraftID, Players.CNDraftPOS, Countries.Nation, Players.NationID, DraftTeam.DrTeam FROM Players Left JOIN CNGHLTeams ON Players.CNGHLID=CNGHLTeams.CNGHLID Left JOIN NHLTeams ON Players.TeamsID=NHLTeams.TeamID Left JOIN Countries ON Players.NationID=Countries.NationID Left JOIN DraftTeam ON Players.DraftID=DraftTeam.DraftID WHERE Players.PlayerID= ORDER BY Players.LastName”

http://www.cnghl.biz/cnghldb/test.php

There you go! Note at the bottom of that text, there is a WHERE Players.PlayerID= NOTHING…
It is not picking up variable which I said was in question. So, it is not sending the the correct
variable named $iPlayerID. It is empty. So, wherever you get that variable from, it is not loading
it with the correct Players.PlayerID. Look back where you create that variable and fix it.
Then, rerun and see if the correct number gets placed into the $Query…

At least we know now…

Hey, been a long day helping people all day long… Might have to quit for a bit… Getting beat!
We made some serious headway, though…

Thanks for your help, I will work on it and let you know how it goes.

Have a good night!

Okay, but, let me know… We are getting so close, I will try to keep checking in… Just get’n tired.

Will be nice to finish this one up… LOL

Sponsor our Newsletter | Privacy Policy | Terms of Service