I am confused as to why the first result which is 0 is not being iterated. Could someone please explain why and show me what needs to be done to show [0]'s result?
Here is my Array:
array(3) { [0]=> string(3) "390" [1]=> string(3) "377" [2]=> string(3) "382" }
Notice how [0] result is not shown via the foreach. The last two which are [1] and [2] show up fine.
You can see the results of this here: http://www.rotaryswing.com/swingviewer/videos.php
<?php
//iterate through video IDS in our DB
foreach ($pieces as $key => $v) {
$sql ="SELECT id, video_name, link, phase FROM videos WHERE id=?";
if ($stmt = $mysqli->prepare($sql)) {
$stmt->bind_param("i", $v);
if ($stmt->execute()) {
$stmt->bind_result($id, $vid_name, $vid_link, $phase);
while ($stmt->fetch()) {
echo "<a style=\"font-size: 14px;\" href='http://www.rotaryswing.com/golf- instruction/video/rst-index.php?cat=$phase&subcat=Rotary%20Swing%20Tour&video=$id&id=$vid_link&name=$vid_name' target=\"blank\">$vid_name</a><br>";
}
}
else {
trigger_error("SQL query failed: " . $stmt->error, E_USER_ERROR);
}
}
}
?>
When I echo just the pieces it echos fine.
<?php echo $pieces[0] . "<br/>";?>
<?php echo $pieces[1] . "<br/>";?>
<?php echo $pieces[2] . "<br/>";?>