brem13 Posted March 4, 2009 Share Posted March 4, 2009 ok, another question, sorry. im still kind of new to this kind of stuff. i have a script that will loop through a folder and display all the pictures in that folder, all of those pictures filenames are in a mysql database with comment fields. im trying to update the comments in the mysql database when i click on update with all the update comments. but it doesnt do anything. i think it has something to do with the files being looped and put in arrays. anyone have any pointers for me please? here is the script that is looping through the directory,displaying the pictures on the page with the comment textbox underneath, and the form to update the mysql database. any help at all will be greatly appreciated ------------------------------------------------------------------------------------------ if ($handle = opendir($cwd)) { /* Read file names */ while (false !== ($file = readdir($handle))) { if (true == is_dir("$cwd$file")) { } else { if(true == is_img($cwd.$file)) { $c++; echo '<td align=center>'; echo '<a href="'.$cwd.'/'.$file.'"><img src="'.$cwd.'/thumbs/'.$file.'"></a><br>'; ?> <form name="comments" action="editgall.php" method="POST"> <font face="tahoma" size="1">Edit: </font> <input type="text" name="comment[]" id="comment1" value="<?php include("../../../../configpic.php"); mysql_connect($server, $db_user, $db_pass) or die (mysql_error()); $result = mysql_db_query($database, "SELECT * FROM $pwd WHERE picture='$file'") or die (mysql_error()); while ($qry = mysql_fetch_array($result)) { echo "$qry[comment]"; } ?>"> <? // echo "<br>".$file."<br>\n"; echo '</td>'; if ($c==4) { echo '</tr><tr>'; $c=0;} } } } closedir($handle); } echo '</tr></table>'; ?> <input type="submit" name="submit" value="update"> </form>Report to moderator 207.127.128.2 Quote Link to comment https://forums.phpfreaks.com/topic/147960-updating-mysql-database-with-fields-in-loop/ Share on other sites More sharing options...
asmith3006 Posted March 4, 2009 Share Posted March 4, 2009 I haven't had time to look closely at the code, but try echo $qry['comment']; instead of echo "$qry[comment]"; Do you get any error messages? Quote Link to comment https://forums.phpfreaks.com/topic/147960-updating-mysql-database-with-fields-in-loop/#findComment-776624 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.