Bruce Gust
asked on
Why does my code skip this cell?
First, here's a look at the page:
I've got a table that consists of 83 cells. The number of rows corresponds to the data that is in a temp table. The idea is to query each cell and see if there's data in it. I'm doing that with this:
So, my logic is:
I'm having trouble in that if you look at my graphic, just below the two big, black errors, you'll notice the sequence of my $y variable "skips." It goes from 31 to 33 and on the same row it skips again from 66 to 68.
Why? Why doesn't cell 32 or 67 show up?
Here's the data as it appears in the database:
You see two entries, both on row one. One has a data start cell of 0, the other has a start cell of 33. I can't understand why my "logic" skips right over cells 32 and 67.
Any ideas?
I've got a table that consists of 83 cells. The number of rows corresponds to the data that is in a temp table. The idea is to query each cell and see if there's data in it. I'm doing that with this:
for($i=1; $i<=$number_of_rows; $i++)
{
for($y=0; $y<=83; $y++)
{
//here is where you define the content, the colspan and the style of the cell. Bear in mind that you'll have to close the cell at this point as well
$statement = $mssql_pdo->prepare("select * from gant_table where DataDisplay_Row='$i' AND DataDisplay_StartCell='$y'");
$statement->execute();
$results=$statement->fetchAll(PDO::FETCH_ASSOC);
if (count($results) > 0)
{
//echo "select * from gant_table where DataDisplay_Row='$i' AND DataDisplay_StartCell='$y'";
foreach($results as $row)
{
include("multi_row.php");
//$body.="</td>"; //BTW you're good up to here
} // this closes your foreach dynamic
} //this closes your results question
else
{
$body.="<td>";
$body.=$y;
$body.="</td>";
}
if($y==83)
{
$body.="</tr><tr>";
}
}
}
So, my logic is:
Loop through each cell and query the database to see if there's data that corresponds to that cell / row number
If there's data, print the background color
If there's no data, simply print an empty cell
If there's data, print the background color
If there's no data, simply print an empty cell
I'm having trouble in that if you look at my graphic, just below the two big, black errors, you'll notice the sequence of my $y variable "skips." It goes from 31 to 33 and on the same row it skips again from 66 to 68.
Why? Why doesn't cell 32 or 67 show up?
Here's the data as it appears in the database:
You see two entries, both on row one. One has a data start cell of 0, the other has a start cell of 33. I can't understand why my "logic" skips right over cells 32 and 67.
Any ideas?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
:-)
ASKER
If you're so inclined, sir, I've got another question that represents the last little "hump" on this project. I've got everything in place in terms of display, but I've got to interact with a MSSQL database and I'm using a MSSQL stored procedure. I've done this before, but in this instance I've got to pass some variables into the proc and it's laughing at me....
https://www.experts-exchange.com/questions/28737412/How-to-I-use-PDO-to-pass-variables-into-a-MSSQL-Stored-Procedure.html
https://www.experts-exchange.com/questions/28737412/How-to-I-use-PDO-to-pass-variables-into-a-MSSQL-Stored-Procedure.html
ASKER
Once that epiphany was applied, the sun broke through the clouds and we are gold.
Thanks!