If you've read any of my previous posts you'll see that I've been trying to format some data using 3 vertical columns.
I've moved away from using xslt and xml and am trying a mysql database.
I'm creating an nhl draft page
How can select a common group (through their Draft round number) from the databse and display in more or less evenly sized columns.
I can get the records i need from the database right now, just can't figure out the syntax to specify to write 10 records in one column, the following 10 in the next column , and the remaing 10 in the last.
Can anyone help tweak my code?
Again, Any help is much apreciated.
PLease ignore the magic mod. I'm trying to get the remainder of division by 3 so as to specify which columns need extra records added on.
Code: Select all
<?php
$host = 'localhost'; // Hostname of MySQL server
$dbUser = 'xxxx'; // Username for MySQL
$dbPass = 'xxxx'; // Password for user
$dbName = 'drafts'; // Database name
// Make connection to MySQL server
if (!$dbConn = mysql_connect($host, $dbUser, $dbPass)) {
die('Could not connect to server');
}
// Select the database
if (!mysql_select_db($dbName, $dbConn)) {
die('Could not select database');
}
// ... some code here using MySQL
// Close the connection when finished
// Define reusable "chunks" of SQL
$table = " FROM {$_GET['league']}";
$where = " WHERE roundnumber='{$_GET['round']}' AND draftyear='{$_GET['year']}' AND LIMIT='{$row['numrows']/3}' ";
// Query to count the rows returned
$sql = "SELECT COUNT(*) as numrows" . $table . $where;
// Run the query, identifying the connection
$queryResource = mysql_query($sql, $dbConn);
$row = mysql_fetch_array($queryResource, MYSQL_ASSOC);
$magicmod = $row['numrows']%3;
$magicdiv = $row['numrows']/3;
// A query to fetch the rows
$sql = "SELECT * " . $table . $where;
// Run the query, identifying the connection
$queryResource = mysql_query($sql, $dbConn);
// Fetch rows from MySQL one at a time
while ($row = mysql_fetch_array($queryResource, MYSQL_ASSOC)) {
echo "<div id=\"pick-odd\"><div id=\"logo\"><img width=\"60\" height=\"60\"src=";
echo "\"{$_GET['league']}/". $row['logo'] .".gif\"></div><div id=\"pick-details\">";
echo "<div id=\"draft-number\">Draft#:". $row ['draftnumber'] ."</div>";
echo "<div id=\"player\">". $row['player'] ."</div>";
echo "Position:". $row['position'] ."<br>";
echo "Drafted From:".$row['draftedfrom']."<br></div> </div>";
}
if ($magicmod == 0){
echo "MAGICMOD = 0!";
echo $magicdiv;
echo $magicmod;
}
if ($magicmod == 1){
echo "MAGICMOD = 1!";
}
if ($magicmod == 2){
echo "MAGICMOD = 2!";
}
mysql_close($dbConn);
?>