我已经搜索了你的问题的答案,我试图用脚本调用一个php文件来检查文件大小并输出一个基于某种类型的数据库表的图像。有人能帮忙吗?
即使undefined index for stocknr
为$row[stocknr]
,我运行时也会收到$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">' . "\n";
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>' . "\n";
}
// 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>';
?>
答案 0 :(得分:0)
you are overwriting the database output with your 5
line, which means that $row['stocknr'] ceases to exist.
As far as I can tell, you don't need that if let allServices = snapshot.childSnapshot(forPath: "Customer").value {
if snapshot.childrenCount == 0 {
self.allService.text = "0"
} else {
self.allService.text = (allServices as AnyObject).count.description
}
}
loop and it can be removed, but I am not sure what you are trying to achieve with the $product array.
As an aside, the foreach($product as $row)
loop can move outside the foreach
loop as it's just rewriting the same values for every row in the database.
Edit: does this do what you want?
for($j = 1; $j <= 30; $j++) {