Forgive me if this has been covered, my searches gave me no answer.
I have a database storing info about pictures. I'm building a website using PHP that queries this DB and returns pics along with some info about the pics. The problem starts with the picture aspect. Some pictures are 800x600, some are 600x800. This presents a problem for neatness in my display popup.
For lack of knowledge of a better way, I have created another field in my DB. It is a field of type BIT that hold whether or not a picture is vertical (TRUE=lateral, FALSE=Vertical.
My query works to pull info, and the results are storedmfine in variables, but I am unable to create a working comparison for the bit field. Here is the relevant code
The relevant comparison is "if ($pic_align==true)". I have tried $pic_align==true, =="true", =="1", ==1, and have had no success. echo $pic_align returns a solid diamond with a question mark in it when the value is false, nothing when true. "is_string($pic_align)" returns "1", but the string is not "true" or "false"
Any ideas on how to use this field in a PHP comparison? Better yet, any ideas for a better solution than the one I've come up with for determining the aspect of a picture? This site is young in development, and I am more concerned with getting it working than I am with display at this point, but this one is important to know. Using bit fields will come up later when I use my audio field as well.
I have a database storing info about pictures. I'm building a website using PHP that queries this DB and returns pics along with some info about the pics. The problem starts with the picture aspect. Some pictures are 800x600, some are 600x800. This presents a problem for neatness in my display popup.
For lack of knowledge of a better way, I have created another field in my DB. It is a field of type BIT that hold whether or not a picture is vertical (TRUE=lateral, FALSE=Vertical.
My query works to pull info, and the results are storedmfine in variables, but I am unable to create a working comparison for the bit field. Here is the relevant code
Code:
$res = mysqli_query($mysqli,$sql); //this works fine ans the query returns the proper data
if ($res) {
$newarray = mysqli_fetch_array($res, MYSQLI_ASSOC);
$pic_id = $newarray['pic_id']; //primary key mediumint
$year = $newarray['year']; // smallint
$event = $newarray['event']; // varchar
$audio = $newarray['audio']; //bit field- not in use yet
$comments = $newarray['comments']; //varchar(255)
$dir1 = $newarray['dir1']; //varchar(20) top level directory
$subdir = $newarray['subdir']; //varchar(20) sub-directory
$filename = $newarray['filename']; //filename with no extension
$pic_align = $newarray['pic_align']; //bit field that is giving me problems
[b]if ($pic_align==TRUE) { //This comaprison is giving me trouble[/b]
echo "\n<table>\n\t<tr>\n\t\t<td colspan=2><img src=\"./slides/".$dir1."/".$subdir."/".$filename.".jpg\"></td>";
echo "\n\t</tr>\n\t<tr>\n\t\t<td>".$year."</td>\n\t\t<td>".$event."</td>";
echo "\n\t</tr>\n\t<tr>\n\t\t<td colspan=2>".$comments."</td>\n\t</tr>";
} else {
echo "\n<table>\n\t<tr>\n\t\t<td rowspan=4><img src=\"./slides/".$dir1."/".$subdir."/".$filename.".jpg\"></td>";
echo "\n\t\t<td>YEAR: ".$year."</td>\n\t</tr>";
echo "\n\t<tr>\n\t\t<td>EVENT: ".$event."</td>\n\t</tr>";
echo "\n\t<tr>\n\t\t<td>DESCRIPTION:</td>\n\t</tr>";
echo "\n\t<tr>\n\t\t<td>".$comments."</td>\n\t</tr>";
}
echo "\n</table>";
} else {
echo("Connect failed: ". mysqli_connect_error());
exit();
}
mysqli_free_result($res);
mysqli_close($mysqli);
The relevant comparison is "if ($pic_align==true)". I have tried $pic_align==true, =="true", =="1", ==1, and have had no success. echo $pic_align returns a solid diamond with a question mark in it when the value is false, nothing when true. "is_string($pic_align)" returns "1", but the string is not "true" or "false"
Any ideas on how to use this field in a PHP comparison? Better yet, any ideas for a better solution than the one I've come up with for determining the aspect of a picture? This site is young in development, and I am more concerned with getting it working than I am with display at this point, but this one is important to know. Using bit fields will come up later when I use my audio field as well.