Hi
I`ve have a code that constructs a table with the appointments entered in a data base by a user. The code should be something like this, though i`ve try many others structures
<form action="delete_app.php" method=post enctype="multipart/form-data">
<table>
<?php foreach($app as $index =>$data_app) {
$data_app =& $app[$index];?>
<tr>
<td><input type="hidden" name="id_service" value="<?php echo $index?>"><?php echo $data_app[0]?></td>
<td><?php echo $data_app[1]?></td>
<td><?php echo $data_app[2]?></td>
<td><?php echo $data_app[3]?></td>
<td><input type="submit" value="Cancel Appoiment" /></td>
<?php unset ($data_app);
}?>
</table>
</form>
The point is that i need to get de data_app[0] value from every appoiment so i can delete the appoiment with another function.
Print_r($app) returns this for a user with three appoiments
Array ( [0] => 164 [IdApp] => 164 [1] => 45 [IdService] => 45 [2] => 2008-11-16 [Date] => 2008-11-16 [3] => 09:00:00 [Hour] => 09:00:00 ) Array ( [0] => 163 [IdApp] => 163 [1] => 3 [IdService] => 3 [2] => 2008-11-16 [Date] => 2008-11-16 [3] => 09:00:00 [Hour] => 09:00:00 ) Array ( [0] => 163 [IdApp] => 163 [1] => 3 [IdService] => 3 [2] => 2008-11-16 [Date] => 2008-11-16 [3] => 09:00:00 [Hour] => 09:00:00
I understand the structure of the $app array and i can get the IdApp that i want using two indexes (print $app [1][0] returns 163 (IdApp)) but i can´t get it dynamically, that is, by clicking the button on the <table>.
Any idea?
foreach index
Moderator: General Moderators
foreach index
Last edited by jacosan on Sat Nov 15, 2008 11:04 am, edited 2 times in total.
Re: foreach index
Always use <?php. Your code will not be portable if you use <? or <?=.
Re: foreach index
thanks syntac, it`s done
Any other idea?
Any other idea?
Re: foreach index
<?php= will not work.
Code: Select all
<?php echo $some_variable; ?>Re: foreach index
Done. Now, any ideas about getting that index dynamically?