iPixel Posted May 30, 2006 Share Posted May 30, 2006 Basically i have a ton of Text boxes and hidden fields and i pass them onto another page...here is how it looks so far >// This pulls all the information if any exists.[code]Include('dbcon.php');$mdl = $_GET['mdl'];$query = "SELECT * FROM gallery_alts WHERE model = '$mdl'";$sql = mysql_query($query) or die(mysql_error());$result = mysql_fetch_assoc($sql);$count = mysql_num_rows($sql);[/code]// This is the form created based upon the amount of images that database contained.// all the database table has is a model : img : and empty field for alt tag (text).[code] <form action="savealts.php" method="post"> <table cellpadding="0" cellspacing="2" class="Thumbnail" width="95%"> <tr> <td bgcolor="9ABC4B" align="center"><font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#FFFFFF">Image Name</font></td> <td bgcolor="9ABC4B" align="center"><font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#FFFFFF">Alt Tag</font></td> </tr> <? $i=0; do { $i++; ?> <tr> <td> <font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#000000"> <? echo $result['img']; ?> </font> </td> <td> <input type="text" value="<? echo $result['alt_tag']; ?>" id="x"> <input type="hidden" value="<? echo $result['img']; ?>" id="x"> </td> </tr> <? } while($result = mysql_fetch_assoc($sql)); ?> <tr> <td colspan="2"> </td> </tr> <tr> <td colspan="2" align="center"> <input type="submit" value="Save Alt Tags" class="savealtbutton"> <input type="hidden" value="<? echo $count; ?>" id="count"> </td> </tr> </table> </form>[/code]Now my question is ... 1> is this ok ..2> how can i pick up all these values on the next page savealts.php and place them into a table.UPDATE gallery_alts SET alt_tag = 'alt tag text box value' WHERE model = 'xxxxx' AND img = 'img text box value'";Hope im clear.. i bad at explaining myself.Here is an Image of what the Alt Tag Form will look like...[a href=\"http://www.pixelsexy.com/AltForm.jpg\" target=\"_blank\"]http://www.pixelsexy.com/AltForm.jpg[/a][a href=\"http://www.pixelsexy.com/MainShot.jpg\" target=\"_blank\"]http://www.pixelsexy.com/MainShot.jpg[/a] Quote Link to comment https://forums.phpfreaks.com/topic/10798-cant-come-up-with-a-good-title-plz-read/ Share on other sites More sharing options...
nogray Posted May 30, 2006 Share Posted May 30, 2006 You can use as many hidden fileds as you want. To access them in the next page, just give them an array name [code]<input type="text" value="<? echo $result['alt_tag']; ?>" id="x" name="alt[]"><input type="hidden" value="<? echo $result['img']; ?>" id="x" name="img[]">[/code]in your next page, the img and alt variables will be normal php arrays[code]$alt_array = $_POST['alt'];$img_array = $_POST['img'];foreach ($alt_array as $alt){........}[/code] Quote Link to comment https://forums.phpfreaks.com/topic/10798-cant-come-up-with-a-good-title-plz-read/#findComment-40395 Share on other sites More sharing options...
iPixel Posted May 31, 2006 Author Share Posted May 31, 2006 Ah.... very cool.Thank You very much for your help.Edted Part Below ==============ok i understand how it works ... and i got it working fine.1 small issue though ...[code]$mdl = $_POST['model'];$alt_array = $_POST['alt'];$img_array = $_POST['img'];foreach ($alt_array as $alt) { CODE HERE }[/code]in the part that says CODE HERE .... how can i use the info from both arrays to create a SQL statement like so :$query = "UPDATE gallery_alts SET alts = '$alt_array element' WHERE model = '$mdl' AND img = '$img_array element'";NOTE : Element 1 of $alt_array should correspond with Element 1 of $img_array.Thanks again for helping Quote Link to comment https://forums.phpfreaks.com/topic/10798-cant-come-up-with-a-good-title-plz-read/#findComment-40546 Share on other sites More sharing options...
iPixel Posted May 31, 2006 Author Share Posted May 31, 2006 WooT !got it ... i think this is a good way to do it ... unless there is a better way.[code]$i=0;foreach ($alt_array as $alt) { echo $alt_array[$i]; echo " - "; echo $img_array[$i]; echo "<BR>"; $i++; }[/code]Thanks Again ! Quote Link to comment https://forums.phpfreaks.com/topic/10798-cant-come-up-with-a-good-title-plz-read/#findComment-40562 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.