BrianM Posted May 22, 2008 Share Posted May 22, 2008 How do I set the max characters allowed in a table cell? Quote Link to comment https://forums.phpfreaks.com/topic/106833-max-characters-in-a-cell/ Share on other sites More sharing options...
AndyB Posted May 23, 2008 Share Posted May 23, 2008 Depends on what you mean. Restricting the input is one way - use maxlength=whatever in a text input Echoing a sub-string of what's in your database is another. If you could explain better what you're trying to achieve, you're likely to get more/better responses. Quote Link to comment https://forums.phpfreaks.com/topic/106833-max-characters-in-a-cell/#findComment-547773 Share on other sites More sharing options...
BrianM Posted May 23, 2008 Author Share Posted May 23, 2008 Well I'm trying to store a report submited from a <textarea></textarea> in a database with the fields -- ID, date, report -- the report field obviously containing the report submitted, which can be several paragraphs long. Well let's say I go to display the entire content of a cell under the report column so that the entire report submitted is output onto a web page that you may want to view later. Well it doesn't display the entire report on the output of the web page, only a limited amount of characters, so I'm not even sure the database is storing the entire report submitted, and maybe a limited amount of text. So really, is what I'm getting at here, how do I store several paragraphs worth of text in a MySQL db cell under the report field, or any field for educational and future reference. Google and other web sites have been no help, nor have I have found any topic which relates to my subject. So I'm hoping I can get some help here. Hope this is a bit more informative. Quote Link to comment https://forums.phpfreaks.com/topic/106833-max-characters-in-a-cell/#findComment-548408 Share on other sites More sharing options...
AndyB Posted May 23, 2008 Share Posted May 23, 2008 Ah. Is the database field type for report text? That will support 65,000 characters. When you retrieve it and want the 'paragraph' breaks to be shown, use the nl2br() function when echoing the database field contents. Quote Link to comment https://forums.phpfreaks.com/topic/106833-max-characters-in-a-cell/#findComment-548466 Share on other sites More sharing options...
BrianM Posted May 27, 2008 Author Share Posted May 27, 2008 I was away on a little vacation. Well I tried using 'text' as the field type and it doesn't let me insert even a paragraph worth of characters, but instead, just a few. Do you need anything like the table structure or the page code, would that help any? Quote Link to comment https://forums.phpfreaks.com/topic/106833-max-characters-in-a-cell/#findComment-551086 Share on other sites More sharing options...
BrianM Posted May 27, 2008 Author Share Posted May 27, 2008 Well now it's letting me insert a satisfying amount of text, but I notice when I add in thing's like apostrophes (') and other characters which aren't letter's or number's it wont insert my entry into the database and completely ignores it. How do I go about telling it to allow special characters like `~!@#$%^&*()-_=+[{]}\|;:'",<.>/? to be inserted into the database? Quote Link to comment https://forums.phpfreaks.com/topic/106833-max-characters-in-a-cell/#findComment-551105 Share on other sites More sharing options...
AndyB Posted May 27, 2008 Share Posted May 27, 2008 All of that is possible, so let's see your form code, your form data processing code, and your sql statements. Quote Link to comment https://forums.phpfreaks.com/topic/106833-max-characters-in-a-cell/#findComment-551211 Share on other sites More sharing options...
BrianM Posted May 27, 2008 Author Share Posted May 27, 2008 Here that is -- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>MPS - Create Report</title> </head> <?php mysql_connect('localhost', 'brian', '*') or die(mysql_error()); mysql_select_db('mps') or die(mysql_error()); if (isset($_POST['report_submit'])) { $sql = "INSERT INTO mps_reports (date, report) VALUES ('".$_POST['report_date']."', '".$_POST['report_text']."')"; $insert = mysql_query($sql); } ?> <body> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <input type="text" name="report_date" value="<?php echo date("F j, Y"); ?>" /> <br /> <textarea name="report_text" cols="50" rows="8"></textarea> <br /> <input type="submit" name="report_submit" value="Send" /> </form> </body> </html> Would it also help to do something like, varchar(10000) - on the report field - since it allows letters, numbers and special characters? Of course replacing 10000 with something a little more suitable for what I need, being higher or lower. Quote Link to comment https://forums.phpfreaks.com/topic/106833-max-characters-in-a-cell/#findComment-551228 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.