PHP - [php] Comments And Reply Script
Hey guys i have been making a comment and reply script. When the user makes a post and others reply they appear below. However when another person makes a post and a reply is made to that they mess up it has the comments at the top and the replys at the bottom. DOes anyone know how i could order these? Or is there a tutorial online. Hope someone can help.
Thanks Similar TutorialsI have a PHP comments filtration/validation script incorporated into my PHP/mysql custom built blog (under development).
This script uses REGEX to evaluate the format of user created comments. This function is supposed to accomplish the following tasks: All code except those in the whitelist must be wrapped in the permitted bbcode tags. The bbcode tags can not be empty The bbcode tags must be used in pairs other forms of bbcode tag must be rejected except if wrapped in the permitted bbcode tag user can not post only code, some descriptive text must be added to explain code. this text can be before or after the code. posted comment string must satisfy minimum and maximum length criteria I shall provide the developer with my current PHP script so he may understand how to lay the script out. If your are good at REGEX, contact me. Thanks. I have a problem with the "comments count" in the toggle link in my blog: www.albertosotophotography.com
I have this script for show/hide comments in main page:
<script type= "text/javascript"> // Show/Hide Comments jQuery(document).ready(function() { // Get #comments div var uniqueAppend = 1; var tempName = 'comments'; while(jQuery("#comments").length > 0 ){ jQuery("#comments").attr('id',tempName + uniqueAppend++).addClass('commentContainer') } var commentsDiv = jQuery('.commentContainer'); // Only do this work if that div isn't empty if (commentsDiv.length) { // Hide #comments div by default jQuery(commentsDiv).hide(); // Append a link to show/hide jQuery('<a/>') .attr('class', 'toggle-comments') .attr('href', '#') .html('Notes') .insertAfter(commentsDiv); // Encase button in .toggle-comments-container div jQuery('.toggle-comments').wrap(jQuery('<div/>', { class: 'toggle-comments-container' })) // When show/hide is clicked jQuery('.toggle-comments').on('click', function(e) { e.preventDefault(); // Show/hide the div using jQuery's toggle() var commentContainer = jQuery(this).parent('.toggle-comments-container').prev('.commentContainer'); jQuery(commentContainer).slideToggle('slow', function() { // change the text of the anchor var anchor = jQuery(commentContainer).siblings('.toggle-comments-container').children('.toggle-comments'); var anchorText = anchor.text() == 'Notes' ? 'Hide' : 'Notes'; jQuery(anchor).html(anchorText); }); }); } // End of commentsDiv.length }); // End of Show/Hide Comments </script>I use: .html('<?php comments_number( '0 notes', '1 note', '% notes' ); ?>')for name the "comments toggle link" with the count of comments for each single post. The problem is that all posts shows the same count: the comments presents in the first post. Someone can help me? Alberto i am making a message system which users can message each other. sending message works fine but having trouble with the reply message cant seem to get to_user value code so far Code: [Select] <?php session_start(); $myusername=$_SESSION['myusername']; require "database.php"; $messageid = $_GET['messageid']; $message = mysql_query("SELECT * FROM messages WHERE message_id = '$messageid' AND to_user = '$myusername'"); $message=mysql_fetch_assoc($message); // problem is here atm getuname returns Resource id instead of the username iam trying to reply to // $getuname= mysql_query("SELECT from_user FROM messages Where message_id='$message_id' AND to_user ='$myusername'"); echo "<h1>Title: ".$message['message_title']."</h1><br><br>"; echo "<h3>From: ".$message['from_user']."<br><br></h3>"; echo "<h3>Message: <br>".$message['message_contents']."<br></h3>"; echo '<form name="backfrm" method="post" action="inbox.php">'; echo '<input type="submit" value="Back to Inbox">'; // this where i need to the to user to carry over to the next page// echo '<a href="reply.php?username=' . "$getuname" . '">reply</a>'."<br/>"; echo '</form>'; ?> </body> </html> Hi can anyone help this is my forum reply code: <?php include "connect.php"; // Get value of id that sent from hidden field $id=$_POST['id']; // Find highest answer number. $sql="SELECT MAX(a_id) AS Maxa_id FROM reply WHERE question_id='$id'"; $result=mysql_query($sql); $rows=mysql_fetch_array($result); // add + 1 to highest answer number and keep it in variable name "$Max_id". if there no answer yet set it = 1 if ($rows) { $Max_id = $rows['Maxa_id']+1; } else { $Max_id = 1; } // get values that sent from form $a_name=$_POST['a_username']; $a_answer=$_POST['a_reply']; // Insert answer $sql2="INSERT INTO reply(question_id, a_id, a_username, a_reply, a_date, a_time)VALUES('$id', '$Max_id', '$a_username', '$a_reply', CURDATE(), CURTIME())"; $result2=mysql_query($sql2); if($result2){ echo "Successful<BR>"; echo "<a href='viewtopic.php?id=".$id."'>View your answer</a>"; // If added new answer, add value +1 in reply column $sql3="UPDATE topic SET reply='$Max_id' WHERE id='$id'"; $result3=mysql_query($sql3); } else { echo "ERROR"; } mysql_close(); ?> and this is the error message anyone know why it gives this Thanks Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/fightwa1/public_html/addreply.php on line 10 please help Hello. My first topic here was about getting the amount of unread messages. I'm now working on showing the unread messages in the inbox. Let's say we have 2 users. User1 sends user2 a message with the title: this is a title. User2 read the message and replied. User1 now has to see: this is a title. This is the code in: class Pm {} public function get_unread_pm() { $stmt = $this->db->prepare(' SELECT pm.title, pm.sender_id, pm.timestamp, (SELECT COUNT(pm2.id) FROM pm as pm1, pm as pm2 WHERE pm1.parent_id=pm2.id) AS replies, u.username as sender FROM pm LEFT JOIN users AS u ON u.id=pm.sender_id WHERE pm.receiver_id=:user_id AND pm.unread=1 AND pm.parent_id=pm.id'); $stmt->bindParam('user_id', $_SESSION['userid']); $stmt->execute(); return $stmt->fetchAll(); } I now get the original message because of the pm.parent=pm.id, but I want to get the message where the parent_id of a reply is the same parent_id as where the parent_id is equal to it's id. I think a less complicated description is: How do I get the last reply instead of the original message?
parent_id: When I reply to a message, my id still counts up, the parent_id is the id of the original message. This is what my data-table looks like:
The content:
If I'm doing this stuff really inefficient, I would be happy to know how to make it better Fabian Edited September 19, 2019 by FabelCan someone assist with this, the form works, but the end user cannot simply click on reply, they have to copy/paste. I think it is just a header issue, but i'm not sure and the person who wrote this script is no longer availalble...any help would be much appreciated! Code: [Select] <?php if ($_POST['post'] != '') { $to = 'fetch@domain.com'; $subject = 'Appointment Request'; $message = "A user on the website has submitted an appointment request. Find their details below.\n\n"; $reqd = array('name', 'email', 'phone', 'phonetype1', 'petname'); $disregard = array('post', 'Appointment_Mail_'); $breaks = array('break', 'break2', 'break3'); foreach($_POST as $key=>$value) { if (in_array($key, $reqd) && $value == '') { $error .= '- Fill out '.$key.'<br />'; } elseif (!in_array($key, $disregard)) { if (in_array($key, $breaks)) { $message .= "\n"; } else { $message .= ucwords($key).": ".stripslashes($_POST[$key])."\n"; } } } if ($error == '') { mail('fetch@domain.com', $subject, $message, 'From: domain.com <noreply@domain.com>'); header('Location: http://www.domain.com/thanks.html'); die(); } else { $error = 'Please correct the following errors:<br />'.$error; } } ?> I want to be able to reply to the sender of the information ( the guy who fills the form online ). your help is much appreciated. here's the code <?php if(isset($_POST['submit'])) { $from = 'From: contactform@nisbetplantation.com'; $to = "reservations@nisbetplantation.com"; $subject = "Website Contact Form"; $name_field = $_POST['name']; $email_field = $_POST['email']; $address_field = $_POST['address']; $address2_field = $_POST['address2']; $city_field = $_POST['city']; $state_field = $_POST['state']; $zip_field =$_POST['zip']; $company_field =$_POST['company']; $IATA_field =$_POST['IATA']; $phone_field =$_POST['phone']; $fax_field =$_POST['fax']; $mail_from="$email"; $response1_field =$_POST['response1']; $areacode_field =$_POST['areacode']; $comments_field =$_POST['comments']; $body = "From: $name_field\n E-Mail: $email_field\n Address:\n $address_field Address2:\n $address2_field City:\n $city_field State:\n $state_field Zip:\n $zip_field Company:\n $company_field IATA:\n $IATA_field Phone:\n $phone_field Fax:\n $fax_field Visited Resort:\n $response1_field Area code:\n $areacode_field Comments:\n $comments_field'"; echo "Your Information has been submitted to $to!"; mail($to, $subject, $body); } else { echo "Please try again after some time..."; } ?> I've already made fully working create topic, etc; what would I need to make to reply to a thread? I've gotten this so far... <?php $result = mysql_query("SELECT id FROM b ORDER BY id DESC"); while ($row = mysql_fetch_array($result, MYSQL_NUM)) { printf("<a href='reply.php?id=%s'>Reply</a><hr><br /><br />", $row[0]); } mysql_free_result($result); ?> reply.php?id=%s (%s equaling the thread id) when I click it, it does bring me to the appropriate page, but I don't know where to go from there. Any help? any other info you might need just ask Hi, I have made personal messaging system however I can't reply unless it is to the last message! I think I've messed up the looping somewhere but can you see if you can figure out what's wrong with it? This is the code for the inbox page: <?php require('scripts/top.php'); ?> <title>Spares List | Your Messages</title> <div id='full'> <?php if ($username){ echo "<a href='create_message.php'>Create Message</a> <div id='box'> <b class='corners'> <b class='corners1'><b></b></b> <b class='corners2'><b></b></b> <b class='corners3'></b> <b class='corners4'></b> <b class='corners5'></b></b> <div class='cornersfg'> <div id='top'>Inbox for $username</div> <div id='bottom' style='padding: 10px;'>"; //////////////////////////////////////////////////////////////////////// require('scripts/connect.php'); $query = mysql_query("SELECT * FROM messages WHERE to_user='$username' ORDER BY id DESC"); $numrows = mysql_num_rows($query); if ($numrows > 0){ echo "<form action='delete_message.php' method='POST'>"; echo "<div id='messages'> <div id='leftside'><input type='checkbox' name='selectall'><input type='submit' name='deleteinbox' value='Delete' class='button'></div> <div id='rightside'>Date</div> <div id='center'>Subject and Message</div> <div style='clear: both;'></div> </div>"; while($row = mysql_fetch_assoc($query)){ $msg_id = $row['id']; $msg_to_user = $row['to_user']; $msg_to_id = $row['to_id']; $msg_from_user = $row['from_user']; $msg_from_id = $row['from_id']; $msg_subject = $row['subject']; $msg_content = $row['content']; $msg_date = $row['date']; $msg_from_delete = $row['from_delete']; $msg_to_delete = $row['to_delete']; if (!$msg_to_delete){ echo "<div id='messages'>"; echo "<div id='leftside'> <input type='checkbox' name='cb$msg_id' value='$msg_id'> <a href='profile.php?id=$msg_from_id' target='_blank'>$msg_from_user</a> </div>"; echo "<div id='rightside'>$msg_date</div>"; echo "<div id='center'> <span class='toggle'><a href='#'>$msg_subject</a></span> <div class='hiddenDiv'> <br>$msg_content<br><br> <span class='toggle'><a href='#'>REPLY</a></span> <div class='hiddenDiv'> <form action='reply.php' method='POST'> <input type='hidden' value='$msg_id' name='replyid'> <input type='text' name='replysubject' style='width: 300px;' class='text-box' value=' $msg_subject'><br> <textarea name='replycontent' style='width: 298px;' rows='5'></textarea><br><br> <input type='submit' name='replybutton' class='button' value='Reply'> </form> </div> </div> </div>"; echo "<div style='clear: both;'></div>"; echo "</div>"; $num += 1; } } if ($num == 0){ echo "You have no messages in your inbox."; } echo "</form>"; } else echo "You have no messages in your inbox."; //////////////////////////////////////////////////////////////////////// echo "</div> </div> <b class='corners'> <b class='corners5'></b> <b class='corners4'></b> <b class='corners3'></b> <b class='corners2'><b></b></b> <b class='corners1'><b></b></b></b> </div>"; ///////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////// echo "<div id='box'> <b class='corners'> <b class='corners1'><b></b></b> <b class='corners2'><b></b></b> <b class='corners3'></b> <b class='corners4'></b> <b class='corners5'></b></b> <div class='cornersfg'> <div id='top'>Outbox for $username</div> <div id='bottom' style='padding: 10px;'>"; //////////////////////////////////////////////////////////////////////// require('scripts/connect.php'); $query = mysql_query("SELECT * FROM messages WHERE from_user='$username' ORDER BY id DESC"); $numrows = mysql_num_rows($query); if ($numrows > 0){ echo "<form action='delete_message.php' method='POST'>"; echo "<div id='messages'> <div id='leftside'><input type='checkbox' name='selectall'><input type='submit' name='deleteoutbox' value='Delete' class='button'></div> <div id='rightside'>Date</div> <div id='center'>Subject and Message</div> <div style='clear: both;'></div> </div>"; while($row = mysql_fetch_assoc($query)){ $msg_id = $row['id']; $msg_to_user = $row['to_user']; $msg_to_id = $row['to_id']; $msg_from_user = $row['from_user']; $msg_from_id = $row['from_id']; $msg_subject = $row['subject']; $msg_content = $row['content']; $msg_date = $row['date']; $msg_from_delete = $row['from_delete']; $msg_to_delete = $row['to_delete']; if (!$msg_from_delete){ echo "<div id='messages'>"; echo "<div id='leftside'> <input type='checkbox' name='cb$msg_id' value='$msg_id'> <a href='profile.php?id=$msg_from_id' target='_blank'>$msg_from_user</a> </div>"; echo "<div id='rightside'>$msg_date</div>"; echo "<div id='center'> <span class='toggle'><a href='#'>$msg_subject</a></span> <div class='hiddenDiv'> <br>$msg_content<br><br> </div> </div>"; echo "<div style='clear: both;'></div>"; echo "</div>"; $num += 1; } } if ($num == 0){ echo "You have no messages in your outbox."; } echo "</form>"; } else echo "You have no messages in your outbox."; //////////////////////////////////////////////////////////////////////// echo "</div> </div> <b class='corners'> <b class='corners5'></b> <b class='corners4'></b> <b class='corners3'></b> <b class='corners2'><b></b></b> <b class='corners1'><b></b></b></b> </div>"; echo "</div>"; } else echo "<center><h2><font color='red'>You must be logged in to view this page.</font></h2></center>"; require('scripts/bottom.php'); ?> And this is the code for the deleteorsend php file: <?php include("header.inc"); ?> <table border="0" width="100%"><tr><td valign="top" width="800"> <div id="content"> <?php //Start Content $replybtn = $_POST['replybutton']; $inboxbtn = $_POST['deleteinbox']; $outboxbtn = $_POST['deleteoutbox']; if($_SESSION['uid']){ if ($replybtn){ $subject = $_POST['replysubject']; $content = $_POST['replycontent']; $replyid = $_POST['replyid']; if ($subject && $content){ $date = date("M d, Y"); $query = mysql_query("SELECT * FROM messages WHERE content='$content' AND date='$date'"); $numrows = mysql_num_rows($query); if ($numrows == 0){ $query = mysql_query("SELECT * FROM messages WHERE id='$replyid' AND to_user='$username'"); $numrows = mysql_num_rows($query); if ($numrows == 1){ $row = mysql_fetch_assoc($query); $to_id = $row['from_id']; $to_user = $row['from_user']; mysql_query("INSERT INTO messages VALUES ('', '$to_user', '$to_id', '$username', '$userid', '$subject', '$content', '$date', '0', '0')"); echo "Your reply has been sent. <a href='messages.php'>Click here</a> to return to your inbox."; } else echo "No message was sent. An error has occured!!!!"; } else echo "You can NOT resend the same messages."; } else echo "You did not supply a subject and/or message."; } else if($inboxbtn){ $query = mysql_query("SELECT * FROM messages WHERE to_user='$username'"); while ($row = mysql_fetch_assoc($query)){ $msg_id = $row['id']; $value = "cb"."$msg_id"; $checkbox = $_POST[$value]; if ($checkbox){ mysql_query("UPDATE messages SET to_delete='1' WHERE id='$msg_id'"); } } echo "The selected messages have been deleted! <a href='messages.php'>Click here</a> to return to your inbox."; } else if($outboxbtn){ $query = mysql_query("SELECT * FROM messages WHERE from_user='$username'"); while ($row = mysql_fetch_assoc($query)){ $msg_id = $row['id']; $value = "cb"."$msg_id"; $checkbox = $_POST[$value]; if ($checkbox){ mysql_query("UPDATE messages SET from_delete='1' WHERE id='$msg_id'"); } } echo "The selected messages have been deleted! <a href='messages.php'>Click here</a> to return to your inbox."; } else echo "You must click the button!"; } else echo "You must be logged in to do that!"; //End Content ?> </div> </td><td width="250"> <?php include("sidebar.inc"); ?> </td> </table> <?php include("footer.inc"); ?> </div> </div> I hope you can work out what is wrong as I am quite new to php. Thanks in advanced Cameron I want to be able to reply to the email of the sender ( of the form ) heres the codes <?php $where_form_is="http://".$_SERVER['SERVER_NAME'].strrev(strstr(strrev($_SERVER['PHP_SELF']),"/")); // Checkbox handling $field_1_opts = $_POST['field_1'][0].",". $_POST['field_1'][1]; mail("harshad@madiganpratt.com","Invitation - Form submission","Form data: rooms: $field_1_opts First Name: " . $_POST['fname'] . " Last Name: " . $_POST['lname'] . " Your Email: " . $_POST['email'] . " Phone Number: " . $_POST['pnumber'] . " Request your arrival date: " . $_POST['field_2'] . " Request your departure date: " . $_POST['field_3'] . " Please send me an ownership package: " . $_POST['field_4'] . " ",$headers); include ("confirm.html"); ?> Hi! I have been on the paypal website a lot but I can't find what I am looking for. I trying to find some API so I can show Paypal links on every page I generate from mysql. When the user press Paypal button, he/or she will be redirected to paypal.com with a form where a field with the ID, already is filled in. So let's say I press Paypal button ,then a ID, to that page will be sent to paypal and when the user pay the money, a reply from paypal with the ID will come back and confirm the payment. How can I get this to work? I really hope you can help me with this! Thanks! what line of code should i add in order to be able to reply to the sender of contact form. right now its showing the last email created in the server. heres the code <?php $where_form_is="http://".$_SERVER['SERVER_NAME'].strrev(strstr(strrev($_SERVER['PHP_SELF']),"/")); // Checkbox handling $field_1_opts = $_POST['field_1'][0].",". $_POST['field_1'][1]; mail("randy@reefsclub.com","Invitation - Form submission","Form data: rooms: $field_1_opts First Name: " . $_POST['fname'] . " Last Name: " . $_POST['lname'] . " Your Email: " . $_POST['email'] . " Phone Number: " . $_POST['pnumber'] . " Request your arrival date: " . $_POST['field_2'] . " Request your departure date: " . $_POST['field_3'] . " Please send me an ownership package: " . $_POST['field_4'] . " ",$headers); include ("confirm.html"); ?> I am working on an http interface to existing apps. These apps make a call to GET a CHUNKED reply with the payload being a Jpg (or series of jpg??) , or a single pdf file
The wireshark trace looks like this: Frame 1093: 209 bytes on wire (1672 bits), 209 bytes captured (1672 bits) on interface \Device\NPF_{9AF84BC1-E1F6-4A31-BC25-33964BBB83EC}, id 0 Ethernet II, Src: Motorola_18:69:75 (84:b8:b8:18:69:75), Dst: IntelCor_f8:a5:5c (a4:34:d9:f8:a5:5c) Internet Protocol Version 4, Src: 192.168.0.150, Dst: 192.168.0.99 Transmission Control Protocol, Src Port: 35138, Dst Port: 8000, Seq: 14994, Ack: 122074, Len: 155 Hypertext Transfer Protocol GET /eSCL/ScanJobs/NextDocument HTTP/1.1\r\n TE: chunked\r\n Host: 192.168.0.99:8000\r\n Connection: Keep-Alive\r\n Accept-Encoding: gzip\r\n User-Agent: okhttp/4.9.1\r\n \r\n [Full request URI: http://192.168.0.99:8000/eSCL/ScanJobs/NextDocument] [HTTP request 98/101] [Prev request in frame: 1091] [Response in frame: 1094] [Next request in frame: 1095] Then I see this in Wireshark, but nothing is ever downloaded the request is made over and over till cancelled: Frame 1094: 1319 bytes on wire (10552 bits), 1319 bytes captured (10552 bits) on interface \Device\NPF_{9AF84BC1-E1F6-4A31-BC25-33964BBB83EC}, id 0 Ethernet II, Src: IntelCor_f8:a5:5c (a4:34:d9:f8:a5:5c), Dst: Motorola_18:69:75 (84:b8:b8:18:69:75) Internet Protocol Version 4, Src: 192.168.0.99, Dst: 192.168.0.150 Transmission Control Protocol, Src Port: 8000, Dst Port: 35138, Seq: 122074, Ack: 15149, Len: 1265 Hypertext Transfer Protocol HTTP/1.1 200 OK\r\n Date: Tue, 13 Jul 2021 11:12:43 GMT\r\n Server: Apache/2.4.48 (Win64) OpenSSL/1.1.1k PHP/8.0.8\r\n Content-Length: 1038\r\n Keep-Alive: timeout=5, max=3\r\n Connection: Keep-Alive\r\n Content-Type: text/html;charset=UTF-8\r\n \r\n [HTTP response 98/101] [Time since request: 0.005202000 seconds] [Prev request in frame: 1091] [Prev response in frame: 1092] [Request in frame: 1093] [Next request in frame: 1095] [Next response in frame: 1096] [Request URI: http://192.168.0.99:8000/eSCL/ScanJobs/NextDocument] File Data: 1038 bytes Line-based text data: text/html (16 lines) <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">\n <html>\n <head>\n <title>Index of /eSCL/ScanJobs/NextDocument</title>\n </head>\n <body>\n <h1>Index of /eSCL/ScanJobs/NextDocument</h1>\n <table>\n <tr><th valign="top"><img src="/icons/blank.gif" alt="[ICO]"></th><th><a href="?C=N;O=D">Name</a></th><th><a href="?C=M;O=A">Last modified</a></th><th><a href="?C=S;O=A">Size</a></th><th><a href="?C=D;O=A">Description</a></th></tr>\n <tr><th colspan="5"><hr></th></tr>\n <tr><td valign="top"><img src="/icons/back.gif" alt="[PARENTDIR]"></td><td><a href="/eSCL/ScanJobs/">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr>\n <tr><td valign="top"><img src="/icons/text.gif" alt="[TXT]"></td><td><a href="index.php">index.php</a> </td><td align="right">2021-07-13 00:43 </td><td align="right">1.0K</td><td> </td></tr>\n <tr><th colspan="5"><hr></th></tr>\n </table>\n <address>Apache/2.4.48 (Win64) OpenSSL/1.1.1k PHP/8.0.8 Server at 192.168.0.99 Port 8000</address>\n </body></html>\n
So how do I get Apache/PHP to respond to this GET CHUNKED request in a way the client understands? Edited July 13 by markosjal Code: [Select] $IP = $_SERVER['REMOTE_ADDR']; $DATE = date("Y-m-d"); $TIME = date("H:i:s"); $NameOfSender = "BLABLABLABALLA"; $email = $fieldnm_3; // use their addy instead of yours $subject = 'ikwerkthuis.be inloggegevens introductie film'; // change subject $text = 'Beste $NameOfSender, Welkom bij ikwerkthuis.be. Hieronder vind U de logingevens voor het bekijken van de introductiefilm: Adres: http://ikwerkthuis.be/index.php/introductie Gebruikersnaam: introductie Paswoord: film2012 %DataOfForm% Wij nemen spoedig contact met u op. Met vriendelijke groeten, Het ikwerkthuis.be team IP: $IP Date: $Date Time: $Time'; // change text mail($email, $subject, $text, 'From: '.$emailadd.''); // send another one out header("Location:$success_page_name"); } ?> Hi all, I'm very new to the wonderful world of php, so I'd appreciate any and all help in the matter. I've greatly simplified the code below to hopefully help you in helping me. Thanks! Ok, so I'm integrating a very simple message board feature into my site. The basic idea is that people post a comment, and have the option of replying to existing comments. I'm definitely not looking for a complete forum; just something that allows users to post and reply. I've tackled the posting bit easily enough. I have a form. Users fill in the form and the message, along with user information, is sent to a MySQL database. The information includes the username(Poster), the message(Message), an id that corresponds to the topic in question(Messid), a unique ID code for the message itself (ID), and a number of other variables like date and rank. I then use a while statement to bring up all of the messages that pertain to a particular topic; The output will only show messages that share the same Messid, and they are arranged in terms of descending ID: Code: [Select] <? while($row = mysql_fetch_array($resultcomments)) { $poster=$row['Poster']; $message= $row['Message']; $ID=$row['ID']; echo $message.$poster.$ID; } So far, so good. What I want is for users to be able to click on any one of the particular messages, and post a response comment that will appear directly below the message to which it responds. Any ideas how I might go about such a task? So far, I've created a new MySQL table that corresponds to these "subcomments". Each subcomment has a "subID" that corresponds to the ID of the message to which it responds. By including a while statement within the while statement above, I can successfully list all of the subcomments that correspond to a message directly below it. The problem, of course, is that I have to insert the subID values manually in php_my_admin. I'm hoping there's a way for php to automatically detect the ID value of the message in question... Many many thanks for any assistance I can get. Once this revolution in communication makes me a billionaire, I will be certain to reward you most properly. Thanks again. Hello, I'm working on this PHP website of my college. Where in after sending the order to the vendor an e-mail is sent to the person who ordered and the head of that department notifying them about the details of order along with that now I need to send a tracking number of every order in that e-mail which gets automatically incremented in subsequent orders. So please let me know how should I approach or do this. Thank you. I have an auto responder in a php order form with the phrase "Our web sites uses a secure order form for customers to purchase products, and services..." When the message is sent, the word 'services' comes out like this: "...products, and 1s." Each instance of the word 'services' is changed to '1s'. Any ideas?
Hello! I'm trying to dive into Dreamweaver's code so that I can better understand what the heck it's doing in order to modify it to my specific needs. My PHP book is great, but it just seems like Dreamweaver's code is much more complicated than how I'd write it based on what I've read about PHP (Disclaimer: been with PHP for a week). It would be incredibly helpful if someone could write comments for each of the lines in terms of what it's doing (the more specific the better). I appreciate that this is a bit of a tedious question to ask, but it would be really appreciated. Thank you. Code: [Select] $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form2")) { $insertSQL = sprintf("INSERT INTO users (first_name, last_name, user_type, email, school_id) VALUES (%s, %s, %s, %s, %s)", GetSQLValueString($_POST['first_name'], "text"), GetSQLValueString($_POST['last_name'], "text"), GetSQLValueString($_POST['user_type'], "text"), GetSQLValueString($_POST['email'], "text"), GetSQLValueString($_POST['school_id'], "int")); mysql_select_db($database_connalgebra, $connalgebra); $Result1 = mysql_query($insertSQL, $connalgebra) or die(mysql_error()); // The code below gives the last autogenerated userid. $id = mysql_insert_id(); $updateusername = "UPDATE users SET username = CONCAT(first_name, $id) WHERE user_id = $id"; $Result2 = mysql_query($updateusername, $connalgebra) or die(mysql_error()); // $insertGoTo = "add_user.php"; if (isset($_SERVER['QUERY_STRING'])) { $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?"; $insertGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $insertGoTo)); } mysql_select_db($database_connalgebra, $connalgebra); $query_rsSchools = "SELECT school_id, school_state, school_city, school_name, school_country FROM schools ORDER BY school_name ASC"; $rsSchools = mysql_query($query_rsSchools, $connalgebra) or die(mysql_error()); $row_rsSchools = mysql_fetch_assoc($rsSchools); $totalRows_rsSchools = mysql_num_rows($rsSchools); Hello im trying to make a comment feature by having a link under my pictures kommentar.php?link=1 Then use the link=1 to see what comments that should be taken from the database. The comments have a linkid like this Linkid: Text: 1 a comment on first picture 1 another comment on first picture 2 a comment on second picture 2 another comment on second picture But i can't get my php to echo all the comments with the linkid of for example 1 without having to get them all separately. This is my script: <?php ob_start(); $host="localhost"; $username="****"; $password="******"; $db_name="db"; $tbl_name="comment"; mysql_connect($host, $username, $password)or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $linkid=filter_input(INPUT_GET,'link'); $sql="SELECT * FROM $tbl_name WHERE linkid='$linkid'"; $result=mysql_query($sql); $grejs=null; while(mysql_fetch_row($result)){ $grejs.="$row[0]"; } echo $grejs; ob_end_flush(); ?> |