so my problem is getting pictures from the database
the code is as follows
Code: Select all
<head>
<title>Tooted: Haakeriistad</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
<!--
img{width: 150px;}
}
-->
</style>
<
</head>
<body bgcolor="#999966" onload="initLightbox()">
<span class="pageName">
<?php
function connect(){
mysql_connect('localhost', 'root', '') or die(mysql_error());;
mysql_select_db('pold');
}
function toode(){
connect();
$sql = "SELECT * FROM traktor";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result, MYSQL_ASSOC)){
echo 'Name: '.$row['name'].'<br />';
echo 'Pilt 1: <img src="trakats/'.$row['pilt1'].'">';
echo 'Pilt 2: <img src="trakats/'.$row['pilt2'].'">';
echo 'Pilt 3: <img src="trakats/'.$row['pilt3'].'"><br />';
echo 'Kirjeldus: '.$row['kirjeldus'].'<br />';
echo 'Hind: '.$row['hind'].'EEK','<br />';
echo '<br />';
}
}
toode();
?>
</span>
</body>
</html>
http://picasaweb.google.com/ulstulst/Un ... 7522752674
As you can see the second row of pictures is a little bit off
I want to get it working so that when I leave the DB fields empty
the empty image signs do not appear
if i left something out please ask
thank you very much
Martin
p.s.
the db is as follows
Code: Select all
-
-- Database: `pold`
--
-- --------------------------------------------------------
--
-- Table structure for table `traktor`
--
CREATE TABLE IF NOT EXISTS `traktor` (
`id` varchar(11) NOT NULL,
`name` varchar(20) NOT NULL,
`pilt1` varchar(20) NOT NULL,
`pilt2` varchar(20) NOT NULL,
`pilt3` varchar(20) NOT NULL,
`kirjeldus` varchar(40) NOT NULL,
`hind` varchar(15) NOT NULL,
UNIQUE KEY `pilt1` (`pilt1`),
UNIQUE KEY `pilt2` (`pilt2`),
UNIQUE KEY `pilt3` (`pilt3`),
UNIQUE KEY `kirjeldus` (`kirjeldus`),
UNIQUE KEY `hind` (`hind`),
UNIQUE KEY `name_2` (`name`),
KEY `id` (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
-- Dumping data for table `traktor`
--
INSERT INTO `traktor` (`id`, `name`, `pilt1`, `pilt2`, `pilt3`, `kirjeldus`, `hind`) VALUES
('', 'traktor', 'maal 132_sized.jpg', 'maal 133_sized.jpg', 'maal 134_sized.jpg', 'no on ju traktor', '5000'),
('', 'trakats', 'maal 146_sized.jpg', '', '', 'öäõü', '77000');