matt_wood87 Posted June 18, 2008 Share Posted June 18, 2008 Hi Guys, i'm having trouble working out the best way to do this; i have an array of image names that correspond to a field in a mysql database, the number of images (array length) can vary each time the query is run. i would like to construct a form based on these images to allow me to enter other information about the pictures into the database. ie. for each element in the array i want a set of input boxes, title, description, rank, that allow me to enter unique data about that specific element in the array, that i can then take and use to update my database. so the page would look like ________________________ image0 title: *text entry box* desc: *text entry box* rank: *number entry box* image1 title: *text entry box* desc: *text entry box* rank: *number entry box* . . . . imagei title: *text entry box* desc: *text entry box* rank: *number entry box* submit button any help on how i might implement this would be much appreciated! Matt Link to comment https://forums.phpfreaks.com/topic/110828-data-entry-forms-generated-in-a-loop/ Share on other sites More sharing options...
moderith Posted June 18, 2008 Share Posted June 18, 2008 mabey with a foreach loop? foreach($a as $b){ echo $b; } Link to comment https://forums.phpfreaks.com/topic/110828-data-entry-forms-generated-in-a-loop/#findComment-568624 Share on other sites More sharing options...
matt_wood87 Posted June 19, 2008 Author Share Posted June 19, 2008 thanks for the reply, but my problem isnt with iterating through the loops, its with generating a variable sized input form, here's my attempts so far that doesn't work, but hopefully should give you the gist of what i'm trying to do: function editDetails($inPhotos, $inPhotosNo) { $imagesDir = 'gallery/thumbs/'; echo 'start of function<br>'; for ($i=0; $i<$inPhotosNo; $i++){ echo '<br>'; ?> <p><img src="<?php echo $imagesDir.'/t'.$inPhotos[$i];?>"/></p> <form action="editarray.php" method="post"> Title: <input type="text" name="<?php echo 'title'.$i;?>" /> Description: <input type="text" name="<?php echo 'desc'.$i;?>" /> Order: <input type="text" name="<?php echo 'order'.$i;?>" /> <input type="submit" /> </form> <?php } and the editarray.php code: <?php include 'config.php'; $date = date("Y-m-d"); echo "hello"; for ($i=0;$i<3;$i++){ echo $_POST["'title'.$i"]; echo $_POST["'desc'.$i"]; echo $_POST["'order'.$i"]; } echo "goodbye"; ?> all this prints out is hellogoodbye thanks for looking Matt Link to comment https://forums.phpfreaks.com/topic/110828-data-entry-forms-generated-in-a-loop/#findComment-568634 Share on other sites More sharing options...
matt_wood87 Posted June 19, 2008 Author Share Posted June 19, 2008 does anyone have any ideas about this? thanks Matt Link to comment https://forums.phpfreaks.com/topic/110828-data-entry-forms-generated-in-a-loop/#findComment-569001 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.