Processing gif in MySQL
IF MySQL result==processing gif file could be included to the resultant MySQL report page
Production Division | ||||||||
Number | Sample Type | Status | ||||||
---|---|---|---|---|---|---|---|---|
1 | Milk | |||||||
2 | Meat | finish | ||||||
3 | Blood | finished | ||||||
4 | Tissue |
Create table as bellow in my_database
CREATE TABLE IF NOT EXISTS `sample` ( `id` int(40) NOT NULL AUTO_INCREMENT, `type` varchar(40) NOT NULL, `status` varchar(40) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ; -- -- Dumping data for table `sample` -- INSERT INTO `sample` (`id`, `type`, `status`) VALUES (1, 'Milk', 'processing'), (2, 'Meat', 'finish'), (3, 'Blood', 'finished'), (4, 'Tissue', 'processing'); |
PHP Display file is as bellow
<?php echo "<center><table bgcolor=#0b2d04> <tr bgcolor=#e6f293><td colspan=9 align='center'>Production Division</td></tr> <tr bgcolor=#327423> <th><font color=#ffffff>Number</font></th> <th><font color=#ffffff>Sample Type</font></th> <th><font color=#ffffff>Status</font></th> </tr>"; $host="localhost"; $username="root"; $password=""; $db_name="my_database"; $tbl_name="sample"; mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $sql="SELECT*FROM $tbl_name"; $result=mysql_query($sql); while ($row = mysql_fetch_assoc($result)){ if ($row['status'] == "processing") { echo "<tr bgcolor=#e6f293> <td>".$row['id']."</td> <td>".$row['type']."</td> <td><img src='processing1.gif'></td> </tr>"; } else { echo "<tr bgcolor=#e6f293> <td>".$row['id']."</td> <td>".$row['type']."</td> <td>".$row['status']."</td> </tr>"; } } echo "</table>"; ?> |
No comments:
Post a Comment