squiblo Posted January 21, 2010 Share Posted January 21, 2010 I have some data in a database (about_me). When there is no data in "about_me", everything works fine and the user can upload data but when data is put in by the user, and the user then wants to edit it again, it doesnt work. This is the php to upload the data <!-- about me upload --> <?php if (isset($_POST['submit_about'])) { if (isset($_POST['textarea_about'])) { $textarea_about = nl2br($_POST['textarea_about']); if (strlen($textarea_about) < 301) { mysql_query("UPDATE page_set_data SET about_me='$textarea_about' WHERE username='$username'"); header("location:http://www.squiblo.com/content.php?content=myhub&myhub=mypage&mypage=mypage&cont=$cont"); } else $about_error = "<ul><li>About you have as maximum of 300 characters.</li></ul>"; } } ?> This gets the data from the database and puts it into variable <?php $about_me_query = mysql_query("SELECT * FROM page_set_data WHERE username='$username'"); while ($row = mysql_fetch_assoc($about_me_query)) { $about_me = nl2br($row['about_me']); } if (!$about_me) { $about_me = "Write about yourself"; } ?> This is the javascript to change from showing the data in textarea or not <script type="text/javascript"> function toggle_visibility(id) { var div = document.getElementById(id); var text = document.getElementById("about_me_text"); if(div.style.display == 'block' ) { div.style.display = 'none'; text.innerHTML = "<?php echo $about_me; ?>"; } else { div.style.display = 'block'; text.innerHTML = "<?php echo $about_error; ?><form action='' method='POST'><textarea cols='23' rows='6' name='textarea_about' id='textarea_about' style='font-family:arial;font-size:13px;overflow:hidden'><?php echo nl2br($about_me);?></textarea><br><input type='submit' name='submit_about' value='Save'> <input type='button' name='cancel_about' value='Cancel' onClick=\"window.location.href='content.php?content=myhub&myhub=mypage&mypage=mypage&cont=<?php echo $cont; ?>'\"></form>"; } } </script> And finaly here is some HTML <div id='about_me_text'> <?php echo $about_me; ?> </div> <div id='about_me_popup' style="display:none"> </div> If you are finding it hard to understand me, please say so and ill link you to the page. Or i you know how to do this and please could you show me a better way for doing this. thanks Quote Link to comment https://forums.phpfreaks.com/topic/189334-phpjava-changing-text/ Share on other sites More sharing options...
MatthewJ Posted January 21, 2010 Share Posted January 21, 2010 What "doesn't work"? Is the update failing? Is the data missing from the textarea? etc. Whether or not you show the textarea or hide it, it still exists within the page so that shouldn't make a difference. On a side note, javascript is not java Quote Link to comment https://forums.phpfreaks.com/topic/189334-phpjava-changing-text/#findComment-999470 Share on other sites More sharing options...
squiblo Posted January 21, 2010 Author Share Posted January 21, 2010 sorry guy, ive just done it AT LAST! Quote Link to comment https://forums.phpfreaks.com/topic/189334-phpjava-changing-text/#findComment-999472 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.