I'm writing a web-based messageboard type app,
I have a script that grabs messages from a MySQL db and then
spit them out in a table with a reply button at the bottom of the message. however, certain messages don't show the reply button, its there in the html code, just not being displayed. I am currently blaming CRs generated by the textarea (by the way i'm not using CGI.pm at this time)
anyway right now what I think I need to do is remove any blank lines at the end of the string, I've already got code for changing line breaks to
and and then back for the reply button, but its still not showing the reply button once in a while
ok enough rambling, here's some code:
foreach( $msg_num = $msg_count -1; $msg_num >= 0; $msg_num--){
foreach( $i = 0; $i < @messages; $i++){
$sth = $dbh->prepare("select $messages[$i] from messages limit $
+msg_num, 1");
$sth->execute;
$messageval[$i] = $sth->fetchrow_array;
$sth->finish;
};
$from = $messageval[0];
$date = $messageval[1];
$subject = $messageval[2];
$message = $messageval[3];
$msg_id = $messageval[4];
$message =~s/(\r\n|\n\r|\r)/<BR>\n/g;
$message =~s/\n{3,}/\n\n/g;
print "<TR><TD>\n";
print "Date: $date<BR>\nFrom: $from<BR>\nSubject: $subject<BR>\nMes
+sage:<BR>\n$message<BR>\n";
print "<FORM METHOD='POST' ACTION='mb_post.pl'>\n";
print "<INPUT TYPE='HIDDEN' NAME='MSG_ID' VALUE='$msg_id'>\n";
print "<INPUT TYPE='HIDDEN' NAME='FROM' VALUE='$from'>\n";
print "<INPUT TYPE='HIDDEN' NAME='DATE' VALUE='$date'>\n";
print "<INPUT TYPE='HIDDEN' NAME='SUBJECT' VALUE='$subject'>\n";
$message = $messageval[3];
$message =~s/(\r\n|\n\r|\r)/\n/g;
print "<INPUT TYPE='HIDDEN' NAME='MESSAGE' VALUE='$message'>\n";
print "<INPUT TYPE='SUBMIT' NAME='REPLY' VALUE='Reply'>\n</FORM>";
print "</TD></TR>\n";
};
also if you have suggestions as to how I can clean or speed this up it will be appreciated :)
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.