I've searched hi and low for an answer to my queston, I'm attempting to call a php file with a script to check file size and output an image based of a database table of a certain type. Would anyone be able to help?
I'm getting a undefined index for stocknr
when I run it even with $row[stocknr]
as $stocknr = $_GET['stocknr']
.
// assume connection
$query = "SELECT year, brand, model, class, stocknr, price, status, pic FROM
stock WHERE class = 'ldv' ORDER BY brand ASC";
// Perform Query
$result = mysqli_query($con,$query);
if (!$result)
{
die("Connection Error: " . mysqli_connect_error());
}
// test array
$product = array();
while ($row = mysqli_fetch_array($result))
{
for($j = 1; $j <= 30; $j++) {
$product[$j]["model"] = "MODEL-$j";
$product[$j]["pic"] = "PIC-$j";
$product[$j]["price"] = "PRICE-$j";
}
// counter for cells
$i = 1;
// begin a table
echo '<table border="1">' . "
";
foreach($product as $row)
// while($row = mysql_fetch_array($result))
{
$title = $row['model'] ;
$uppic = $row['pic'];
$price = $row['price'];
// for 1st, 6th, 11th etc record insert a tag for a new row
if (($i == 1) or (($i - 1) % 4) == 0) {
echo '<tr>' . "
";
}
// insert a cell
echo ("<td width=150 align=center>");
echo ("<a href=../imagesize.php?scode=$uppic><img
src=images/'$uppic'.jpg border=0 alt=Item $title</a>");
// $row[stocknr]?
echo ("<br><a href=\"details.php?stocknr=$row[stocknr]\">
<span class=fs13>$title</span></a>");
echo ("</td>");
echo ("<tr height=150>");
echo ("<a href=\"details.php?stocknr=$row[stocknr]\">
<span class=sapri>$price</span></a>");
// for 5th, 10th, 15th etc record insert a tag for end of the row
if ((($i) % 5) == 0) {
echo '</tr>';
}
// increment $i
$i++;
}
}
// filling row with empty cells
while(($i - 1) % 5 != 0) {
// insert a blank cell
echo '<td> </td>';
// increment $i
$i++;
// for 5th, 10th, 15th etc record insert a tag for end of the row
if (($i - 1) % 5 == 0) {
echo '</tr>';
}
}
// end the table
echo '</table>';
?>