Forum Moderators: coopster
<html>
<head>
<title>Barkan-Proizvodi</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<p><?php include("header.html"); ?></p>
<table width="1103" height="96" border="0.1">
<tr>
<td width="215" height="92" valign="top"><?php include("menu.html"); ?>;</td>
<td width="878"><table width="86%" border="0" align="left" bordercolor="#999999">
<tr class="row">
<td>Slika</td>
<td>Naziv artikla</td>
<td>Opis</td>
<td>Detaljnije</td>
</tr>
<?php
$connection = mysql_connect("localhost", "root", "") or die("Error connecting to database");
mysql_select_db("glavna", $connection);
$result = mysql_query("SELECT * FROM proizvodi ORDER BY rbr", $connection) or die("error querying database");
$i = 0;
while($result_ar = mysql_fetch_assoc($result)){
?>
<tr <?php if($i%2 == 1){ echo "class='body2'"; }else{echo "class='body1'";}?>>
<td height="33"><img src="/test/<?php echo $result_ar['slika']; ?>" width="80" height="80"></td>
<td> <?php echo $result_ar['naziv_artikla']; ?></td>
<td> <?php echo $result_ar['opis']; ?></td>
<td> <?php echo"<a href='proizvod.php?rbr=$result_ar[rbr]'>$rbr Detaljnije</a>";?> </td>
</tr>
<?php
$i+=1;
}
?>
</table></td>
</tr>
</table>
<p> </p>
<p>
<?php include("footer.htm"); ?>
</p>
</body>
</html> "SELECT * FROM proizvodi WHERE rbr=$rbr" <td> <?php echo"<a href='proizvod.php?rbr=$result_ar[rbr]'>$rbr Detaljnije</a>";?> </td> Using double quotes you need to add the vars to the string, I consider this to be tidier and easier to read, though I can guess as Readie will disagree with me there (just my preference Readie!)
'SELECT * FROM proizvodi WHERE rbr = "' . $rbr . '"'
but it won't working.
$out=null; // squelch undefined variable errors due to concatenation
while($result_ar = mysql_fetch_assoc($result)) {
//
$style = ($i%2 == 1)?'class="body2"':'class="body1"';
$out .= "
<tr $style>
<td height=\"33\"><img src=\"/test/" . $result_ar['slika'] . "\" width=\"80\" height=\"80\"></td>
<td>" . $result_ar['naziv_artikla'] . "</td>
<td>" . $result_ar['opis'] . "</td>
<td><a href=\"proizvod.php?rbr=" . $result_ar['rbr'] . "\"> $rbr Detaljnije</a></td>
</tr>
";
$i++; // Terse version of += 1
}
// Output once
echo $out;
<a href="proba.php?=<?php echo $result_ar['rbr']; ?>[b]"[/b]> <?php echo $rbr;?>Detaljnije</a> "SELECT * FROM proizvodi where rbr=1" <a href="proba.php"</a> http://localhost/test/proizvod.php?rbr=1 for the first table row. there is an exception in second page saying "Query was empty", I am gonna look into that.
Some example for catch the data using $_GET['rbr']?
<a href="proizvod.php?rbr=<?php echo $result_ar['rbr']; ?>"><?php echo $rbr;?> Detaljnije</a> $rbr = $_GET['rbr'];
$connection = mysql_connect("localhost", "root", "") or die("Error connecting to database");
mysql_select_db("glavna", $connection);
$result = mysql_query("select * from proizvodi where rbr=$rbr", $connection) or die("error querying database");