Removing Single Element From Array
Posted: Wed Jun 12, 2002 3:23 pm
Howdy all,
I've been trying to figure this out for the past two hours, and still nothing. I have an array with seven items (0-6), and want the user to be able to remove one of the items with a link. Here is the code (without the input form):
Albeit not the cleanest code, it *should* function, according to my understanding. It will print the array into an alternating color table, with a delete link next to each one, that transmits the action (delete) and id of each specific element.
If someone can tell me why the code doesn't work, or modify it so that it does work, I'd be GREATLY appreciative.
Thanks in advance!
Martin
I've been trying to figure this out for the past two hours, and still nothing. I have an array with seven items (0-6), and want the user to be able to remove one of the items with a link. Here is the code (without the input form):
Code: Select all
<?php
if($action == "delete") {
unset($itemї$id]);
}
$color = "#336699";
var_dump($item);
for($counter = 0; $counter < 7; $counter++) {
$offset = $counter + 1;
echo "<tr><td width="80%" bgcolor="$color">\n";
echo "Item " . $offset . ": " . $itemї$counter];
echo "</td>\n";
echo "<td width="20%" bgcolor="$color">\n";
echo "<a href="makelist.php?action=delete&id=$counter" class="link">Delete</a>\n";
echo "</td></tr>\n\n";
if($color == "#336699") {
$color = "#6699CC";
} else {
$color = "#336699";
}
}
?>If someone can tell me why the code doesn't work, or modify it so that it does work, I'd be GREATLY appreciative.
Thanks in advance!
Martin