Jump to content

Newbie - Please help me!


Henrik

Recommended Posts

Hi,I have changed a basic forum script into a program listing script which works fine. My problem is that I like to have a list of members watching the program listed below the program details, they click "join" to be added to the list.My problem:Right now I can only get a list of members watching ALL programs (nForumId` = nForumId) or (nForumId` = 2) it will show all members watching program no. 2 which then is showed below allprograms and is wrong...This is the "nexus_programmembers" table I am using:nForumMemberId nForumId nUserId 1 1 1 2 2 1 3 1 2 4 2 2 This is my code:$data = mysql_query("SELECT nexus_programmembers.nForumId,nexus_programmembers.nUserId, nexus_users.cUsername from nexus_programmembers, nexus_users where nexus_programmembers.nUserId=nexus_users.nUserId and `nForumId` = nForumId")I appreciate any help as I am really stuck here...Thanks in advance!HenrikPS. if you need further info then please let me know

Link to comment
Share on other sites

This is why you are getting all members:`nForumId` = nForumIdThat is like saying where 1=1. You need to substitute a specific ID into there to get the people watching a certain program.$forumID = 5;$data = mysql_query("SELECT nexus_programmembers.nForumId,nexus_programmembers.nUserId, nexus_users.cUsername from nexus_programmembers, nexus_users where nexus_programmembers.nUserId=nexus_users.nUserId and `nForumId` = {$forumID}")

Link to comment
Share on other sites

Hi,Thanks for the quick reply! Yes, I fully understand what you are saying I am not sure how to get it out right, please take a look here:http://solixta.com/nexus/programs.php?acti...m&forumid=2 which is right because I set "$forumID = 2;".if you go to http://solixta.com/nexus/programs.php?acti...m&forumid=3, that one is naturally wrong because I set "$forumID = 2;" I just don´t know how to get it right so I have copied the complete script here,may you can take a look what need to get altered. You can use search for "$forumID = 2;" to get to the place in the script.I appreciate your assistance!Henrik

<?phpinclude "./lib/session.php";include "./lib/config.php";include "./lib/database.php";include "./lib/misc.php";include "./lib/html.php";$html = html_page_start("Programs");// left hand side$html .= html_menu_side();$html .= html_page_sep();// content$html .= "<table border='0' cellspacing='0' cellpadding='0'><tr>" ."<td><img src='images/ws1.gif' width='100' height='90' title='".$site_short_name." Programs'></td>" ."<td width='5'> </td>" ."<td><div class='title'><font color='#4A63DE'>SoliXta Member Programs </font></div></td>\n" ."</tr></table>\n" ."<p class='body'>Welcome to the SoliXta Member Programs, where you can find all programs presently listed with SoliXta.<br> Is a program not listed with SoliXta yet then please click <a href='xxx'>HERE</a> to have it listed - <b>remember</b> when we add the program to our database we will use your affiliate link so you really do benefit!.<center>\n"; $con = db_connect(); $sql="SELECT nForumId, cTitle FROM nexus_programs"; $result=mysql_query($sql); $options=""; while ($row=mysql_fetch_array($result)) { $nForumId=$row["nForumId"]; $cTitle=$row["cTitle"]; $options.="<OPTION VALUE=\"programs.php?action=view_forum&forumid=$nForumId\">".$cTitle;'</option>';} $html .= "<FORM NAME='menu'> <SELECT NAME='cTitle' ONCHANGE='fieldchange(menu)' SIZE='-1'><OPTION VALUE=''><?=$options?></OPTION></SELECT> </form></center></p>\n";// if action is not set, show the front pageif ($_GET["action"]==""){ $html .= "<div style='padding:20px;'>\n"; // list the forums themselves $con = db_connect(); $sql = "SELECT f.nSort,f.nForumId,f.cTitle,f.cSummary,f.nPosts,f.nTopics,f.nOwnerId,uo.cUsername AS cOwner,f.nLastPostBy,ul.cUsername AS cLastPoster,f.dLastPost,f.nLastPostId" ." FROM nexus_programs f" ." INNER JOIN nexus_users uo ON f.nOwnerId=uo.nUserId" ." LEFT OUTER JOIN nexus_users ul ON f.nLastPostBy=ul.nUserId" ." ORDER BY nSort DESC,cTitle"; // start the common border $html .= "<table border='0' cellspacing='1' cellpadding='2' width='100%' bgcolor='#4A63DE'>\n" ."<tr><td bgcolor='#4A63DE' class='small'> <font color='#ffffff'><b>Program List</b></font></td></tr>\n" ."<tr><td bgcolor='#ffffff'><div style='padding:5px;'>\n"; $result = mysql_query($sql,$con); if ($result!=false){ if (mysql_num_rows($result)>0){ $html .= "<table width='100%' border='0' cellspacing='1' cellpadding='3' bgcolor='#4A63DE'>\n"; while ($row =@ mysql_fetch_array($result)){ $html .= "<tr><td bgcolor='#ffffff'>\n" ."<div class='normal'><li><a class='link' href='programs.php?action=view_forum&forumid=".$row["nForumId"]."'><b><font size='2'>".stripslashes($row["cTitle"])."</font></b></a></li></div>\n" ."<div class='small' style='padding-left:10px;'>Submitted by : <a href='user_view.php?userid=".$row["nOwnerId"]."'>".stripslashes($row["cOwner"])."</a></div>\n" ."<div class='small' style='padding-left:10px;'>".$row["nTopics"]." topics, ".$row["nPosts"]." posts, last post by <a href='user_view.php?userid=".$row["nLastPostBy"]."'>".stripslashes($row["cLastPoster"])."</a> on ".$row["dLastPost"]." <a href='programs.php?action=view_topic&postid=".$row["nLastPostId"]."#".$row["nLastPostId"]."' title='Read Post'>»</a></div>\n" ."<div class='normal' style='padding-left:10px;'>".stripslashes($row["cSummary"])."</div>\n" ."<div class='small' style='padding-left:10px;'>Click <a href='programs.php?action=view_forum&forumid=".$row["nForumId"]."'>here</a> for reviews and info.</div>\n" ."</td></tr>\n"; } $html .= "</table>\n"; } else { // no forums to list } } else { $html .= "<div class='small'>problem with SQL [".$sql."]</div>\n"; } // finish the common border $html .= "</div></td></tr>\n" ."</table>\n"; $html .= "</div>\n";}// if action is 'view_forum' show the topics in a forumif ($_GET["action"]=="view_forum"){ $con = db_connect(); // get the user membertype if ($_SESSION["nexus_userid"]!=""){ $sql = "SELECT cType FROM nexus_programmembers WHERE nUserId=".$_SESSION["nexus_userid"]." AND nForumId=".$_GET["forumid"]; $result = mysql_query($sql,$con); if ($result!=false){ if (mysql_num_rows($result)>0){ $row = mysql_fetch_array($result); $member_type = $row["cType"]; } else { // no records $member_type=""; } } else { // problem with SQL $html .= "<div class='small'>Problem with SQL [".$sql."]</div>\n"; } } // start putting the page together $html .= "<table border='0' cellspacing='1' cellpadding='2' width='100%' bgcolor='#4A63DE'>\n" ."<tr><td bgcolor='#4A63DE' class='small'><form> <font color='#ffffff' size='2' face='arial'><b>Program Description</b> <input type='button' value='Go Back' onclick='history.back();'></form></font></td></tr>\n" ."<tr><td bgcolor='#ffffff'><div style='padding:5px;'>\n"; // show the forum name $sql = "SELECT f.nForumId,f.cType,f.cStatus,f.cTitle,f.cSummary,f.nPosts,f.nTopics,f.nOwnerId,uo.cUsername AS cOwner,f.nLastPostBy,ul.cUsername AS cLastPoster,f.dLastPost,f.nLastPostId,f.ProgUrl,f.BanUrl,f.ProgDetails" ." FROM nexus_programs f" ." INNER JOIN nexus_users uo ON f.nOwnerId=uo.nUserId" ." LEFT OUTER JOIN nexus_users ul ON f.nLastPostBy=ul.nUserId" ." WHERE nForumId=".$_GET["forumid"]; $result = mysql_query($sql,$con); if ($result!=false){ if (mysql_num_rows($result)>0){ $row = mysql_fetch_array($result); switch($member_type){ case "owner": $html_new = "<div class='normal'><a href='programs.php?action=new_topic&forumid=".$_GET["forumid"]."'><b>Post Your Review</b></a></div>"; break; case "moderator": $html_newtopic = "<div class='normal'><a href='programs.php?action=new_topic&forumid=".$_GET["forumid"]."'><b>Post Your Review</b></a></div>"; break; case "member": $html_newtopic = "<div class='normal'><a href='programs.php?action=new_topic&forumid=".$_GET["forumid"]."'><b>Post Your Review</b></a></div>"; break; case "pending": $html_newtopic = "<div class='normal'><b>You Cannot Post</b><br>Your membership of this forum is pending approval of its owner.</div>"; break; case "banned": $html_newtopic = "<div class='normal'><b>You Cannot Post</b><br>You have been banned from posting to this forum.</div>"; break; default: switch($row["cType"]){ case "open": // user is joined immediately on join request $html_newtopic = "<div class='normal'><a href='programs_exec.php?action=join_forum&forumid=".$row["nForumId"]."'><b>Join</b></a><br>If you like to watch this program<br>please click 'Join' above.</div>"; break; case "managed": // user is added as pending on join request $html_newtopic = "<div class='normal'><a href='programs_exec.php?action=join_forum&forumid=".$row["nForumId"]."'><b>Join</b></a><br>This is a managed forum<br>click 'Join' to request membership.</div>"; break; } break; } // figure out if the forum is open or not if ($row["cStatus"]=="live"){ $html .= "<table border='0' cellspacing='0' cellpadding='0' width='100%'><tr><td>"; $html .= "<div class='normal'> <a href='".stripslashes($row["ProgUrl"])."' target='blank'><img src='".stripslashes($row["BanUrl"])."' border='0' width='468' height='60'></a></div>\n" ."<div class='large'><font size='2'>Program:</font>".stripslashes($row["cTitle"])." <font size='1'><a href='".stripslashes($row["ProgUrl"])."' target='blank'><font face='arial'>[GO TO PROGRAM]</font></a></font></div>\n" ."<div class='normal'>Submitted by : <a href='user_view.php?userid=".$row["nOwnerId"]."'>".stripslashes($row["cOwner"])."</a></div>\n" ."<div class='normal'><br><b><i>".stripslashes($row["ProgDetails"])."</i></b><br></div>\n" ."<div class='small'> </div>\n" ."<div class='normal'>".$row["nTopics"]." Review(s), ".$row["nPosts"]." Reviews/Comments, last active <a href='user_view.php?userid=".$row["nLastPostBy"]."'>".stripslashes($row["cLastPoster"])."</a> <br>on ".$row["dLastPost"]." <a href='programs.php?action=view_topic&postid=".$row["nLastPostId"]."#".$row["nLastPostId"]."' title='Read Post'>»</a></div>\n" ."<div class='small'> </div>\n" ."<div class='normal'><b>* ".stripslashes($row["cSummary"])."</b></div>\n"; $html .= "</td><td align='center' valign='bottom' width='150'>"; if ($_SESSION["nexus_userid"]!=""){ $html .= $html_newtopic; } else { $html .= "<div class='normal'><b>Login Required</b><br>You need to login before you can post reviews/comments.</div>\n"; } $html .= "</td></tr></table>\n"; } if ($row["cStatus"]=="pending"){ $html .= "<div class='large'>".stripslashes($row["cTitle"])."</div>\n" ."<div class='normal' style='padding:20px;'>This forum has been requested for creation, but has not been enabled yet. Please contact the administrator if you have any questions, or would just like to lean on him a bit :)</div>\n"; } if ($row["cStatus"]=="closed"){ $html .= "<div class='large'>".stripslashes($row["cTitle"])."</div>\n" ."<div class='normal' style='padding:20px;'>This forum has been closed. Please contact the administrator if you have any questions.</div>\n"; } } else { // no forums to list } } else { $html .= "<div class='small'>problem with SQL [".$sql."]</div>\n"; } $html .= "</div></td></tr><tr><td bgcolor='#eeeeee'><div style='padding:5px;'>\n"; if ($row["cStatus"]=="live"){ // get the posts $sql = "SELECT t.nTopicId,t.cTitle AS cTopicTitle,t.nForumId,f.cTitle AS cForumTitle,t.nFirstPostId,t.nLastPostId,uf.cUsername AS cFirstPostBy,ul.cUsername AS cLastPostBy,t.nFirstPostBy,t.nLastPostBy,t.dFirstPost,t.dLastPost,t.nPosts,t.nViews" ." FROM nexus_reviews t" ." INNER JOIN nexus_programs f ON t.nForumId=f.nForumId" ." INNER JOIN nexus_users uf ON t.nFirstPostBy=uf.nUserId" ." INNER JOIN nexus_users ul ON t.nLastPostBy=ul.nUserId" ." WHERE t.nForumId=".$_GET["forumid"] ." ORDER BY t.dLastPost DESC;"; $result = mysql_query($sql,$con); if ($result!=false){ $html .= "<table border='0' cellspacing='1' cellpadding='2' bgcolor='#4A63DE' width='100%'>" ."<tr><td colspan='6' bgcolor='#4A63DE' class='small'> <font color='#ffffff'><b>Reviews</b></font></td></tr>" ."<tr>" ."<td bgcolor='#ffcc00' class='small'>Review Headline</td>" ."<td bgcolor='#ffcc00' class='small' width='40'>Views</td>" ."<td bgcolor='#ffcc00' class='small' width='40'>Posts</td>" ."<td bgcolor='#ffcc00' class='small' width='150'>Reviewed By</td>" ."<td bgcolor='#ffcc00' class='small' width='150'>Latest Review/Commment</td>" ."</tr>\n"; if (mysql_num_rows($result)>0){ while ($row =@ mysql_fetch_array($result)){ $html .= "<tr>" ."<td bgcolor='#ffffff' class='normal'><a href='programs.php?action=view_topic&topicid=".$row["nTopicId"]."'><b>".$row["cTopicTitle"]."</b></a></td>\n" ."<td bgcolor='#ffffff' class='normal' width='40'>".$row["nViews"]."</td>\n" ."<td bgcolor='#ffffff' class='normal' width='40'>".$row["nPosts"]."</td>\n" ."<td bgcolor='#ffffff' class='small' width='150'><a class='link' href='user_view.php?userid=".$row["nFirstPostBy"]."'>".stripslashes($row["cFirstPostBy"])."</a><br>".$row["dFirstPost"]." <a href='programs.php?action=view_topic&postid=".$row["nFirstPostId"]."#".$row["nFirstPostId"]."' title='Read Post'>»</a></td>\n" ."<td bgcolor='#ffffff' class='small' width='150'><a class='link' href='user_view.php?userid=".$row["nLastPostBy"]."'>".stripslashes($row["cLastPostBy"])."</a><br>".$row["dLastPost"]." <a href='programs.php?action=view_topic&postid=".$row["nLastPostId"]."#".$row["nLastPostId"]."' title='Read Post'>»</a></td>\n" ."</tr>\n"; } } else { $html .= "<tr><td bgcolor='#ffffff' class='small' align='center' colspan='6'>No Reviews were posted yet.<hr size='1'>".$html_newtopic."</td></tr>\n"; } $html .= "</table>\n"; //new list program members $con = db_connect(); $forumID = 2; $data = mysql_query("SELECT nexus_programmembers.nForumId,nexus_programmembers.nUserId, nexus_users.cUsername from nexus_programmembers, nexus_users where nexus_programmembers.nUserId=nexus_users.nUserId and `nForumId` = {$forumID}") or die(mysql_error()); $html .= "<br><table border='0' cellspacing='1' cellpadding='2' bgcolor='#4A63DE' width='100%'>\n"; $html .= "<tr><td colspan='6' bgcolor='#4A63DE' class='small'> <font color='#ffffff'><b>Members Watching This Program</b></font></td></tr>\n"; while($info = mysql_fetch_array( $data )) { $html .= "<tr><td bgcolor='#ffffff' class='small'> <img src='images/icon_yahoo.png' width='16' height='16' align='absmiddle'> <a href='user_view.php?userid=".$info['nUserId'] . "'>".$info['cUsername'] . "</a></td></tr>\n"; } $html .= "</table>\n"; //end new list program members } else { // no forum to show $html .= "<p align='center' class='small'>Problem with the SQL [".$sql."]</p>\n"; } } else { // forum is not live $html .= "<div class='normal' style='text-align:center;'>The program contents cannot be shown while it's status is 'offline'.</div>"; } $html .= "</div></td></tr>\n" ."</table>\n";}// if action is 'view_topic' show a single topic in a forumif ($_GET["action"]=="view_topic"){ $con = db_connect(); // see if we were given a postid (i.e. we will need to find out the topic from it $postid = $_GET["postid"]; if($postid!=""){ $sql = "SELECT nTopicId FROM nexus_ratings WHERE nPostId=".$postid; $result = mysql_query($sql,$con); if ($result!=false) { if (mysql_num_rows($result)>0){ $row = mysql_fetch_array($result); $topicid = $row["nTopicId"]; } else { // no such post } } else { // problem with SQL } } else { $topicid = $_GET["topicid"]; } // update the view stats for the topic $sql = "UPDATE nexus_reviews SET nViews=nViews+1 WHERE nTopicId=".$topicid; $result = mysql_query($sql,$con); // get the topic name, forumid and forumtype (use forum type to influence buttons available) $sql = "SELECT t.cTitle,t.nForumId,f.cType AS cForumType" ." FROM nexus_reviews t" ." INNER JOIN nexus_programs f ON t.nForumId=f.nForumId" ." WHERE t.nTopicId=".$topicid; $result = mysql_query($sql,$con); if ($result!=false){ if (mysql_num_rows($result)>0){ $row = mysql_fetch_array($result); // store the title of the topic away for use at the top of the thread of messages $forumid = $row["nForumId"]; $topic_title = stripslashes($row["cTitle"]); $forum_type = $row["cForumType"]; // get the user membertype for the forum if ($_SESSION["nexus_userid"]!=""){ $sql = "SELECT cType FROM nexus_programmembers WHERE nUserId=".$_SESSION["nexus_userid"]." AND nForumId=".$row["nForumId"]; $result = mysql_query($sql,$con); if ($result!=false){ if (mysql_num_rows($result)>0){ $row = mysql_fetch_array($result); $member_type = $row["cType"]; } else { // no records $member_type=""; } } else { // problem with SQL } } // now figure out what to show for addtopic and reply links // (make them context sensitive to the type of forum and the membership status of the user) switch($member_type){ case "owner": $html_newtopic = "<div class='normal'><a href='programs.php?action=new_topic&forumid=".$row["nForumId"]."'><b>Post Your Review</b></a></div>"; $html_reply = "<span class='normal'><a href='programs.php?action=reply&forumid=[forumid]&topicid=[topicid]&postid=[postid]'><b>Post Your Comments</b></a></span>"; break; case "moderator": $html_newtopic = "<div class='normal'><a href='programs.php?action=new_topic&forumid=".$row["nForumId"]."'><b>Post Your Review</b></a></div>"; $html_reply = "<span class='normal'><a href='programs.php?action=reply&forumid=[forumid]&topicid=[topicid]&postid=[postid]'><b>Post Your Comments</b></a></span>"; break; case "member": $html_newtopic = "<div class='normal'><a href='programs.php?action=new_topic&forumid=".$row["nForumId"]."'><b>Post Your Review</b></a></div>"; $html_reply = "<span class='normal'><a href='programs.php?action=reply&forumid=[forumid]&topicid=[topicid]&postid=[postid]'><b>Post Your Comments</b></a></span>"; break; case "pending": $html_newtopic = "<div class='normal'><b>You Cannot Post</b><br>Your membership of this forum is pending approval of its owner.</div>"; $html_ = "<span class='normal'>Membership Pending - <b>Cannot Reply</b></span>"; break; case "banned": $html_newtopic = "<div class='normal'><b>You Cannot Post</b><br>You have been banned from posting to this forum.</div>"; $html_reply = "<span class='normal'><b>You Cannot Post</b><br>You have been banned from posting to this forum.</span>"; break; case "": switch($forum_type){ case "open": // user is joined immediately on join request $html_newtopic = "<div class='normal'><a href='programs_exec.php?action=join_forum&forumid=".$row["nForumId"]."'><b>Join</b></a><br>This is an open forum<br>just click 'Join' to join.</div>"; $html_reply = "<span class='normal'><a href='programs_exec.php?action=join_forum&forumid=".$row["nForumId"]."'><b>Join</b> to Post Your Comments</a></span>"; break; case "managed": // user is added as pending on join request $html_newtopic = "<div class='normal'><a href='programs_exec.php?action=join_forum&forumid=".$row["nForumId"]."'><b>Join</b></a><br>This is a managed forum<br>click 'Join' to request membership.</div>"; $html_reply = "<span class='normal'>Managed Forum - <a href='programs_exec.php?action=join_forum&forumid=".$row["nForumId"]."'><b>Join</b> to Post Your Comments</a></span>"; break; } break; } //$html .= "<div class='large'>NEW [".$html_newtopic."]</div>\n"; // start putting the page together $html .= "<table border='0' cellspacing='1' cellpadding='2' width='100%' bgcolor='#4A63DE'>\n" ."<tr><td bgcolor='#4A63DE' class='small'><form> <font color='#ffffff' size='2' face='arial'><b>Program Description</b> <input type='button' value='Go Back' onclick='history.back();'></form></font></td></tr>\n" ."<tr><td bgcolor='#ffffff'><div style='padding:5px;'>\n"; // show the forum name $sql = "SELECT f.nForumId,f.cTitle,f.cSummary,f.nPosts,f.nTopics,f.nOwnerId,uo.cUsername AS cOwner,f.nLastPostBy,ul.cUsername AS cLastPoster,f.dLastPost,f.nLastPostId" ." FROM nexus_programs f" ." INNER JOIN nexus_users uo ON f.nOwnerId=uo.nUserId" ." INNER JOIN nexus_users ul ON f.nLastPostBy=ul.nUserId" ." WHERE nForumId=".$forumid; $result = mysql_query($sql,$con); if ($result!=false){ if (mysql_num_rows($result)>0){ $row = mysql_fetch_array($result); $html .= "<table border='0' cellspacing='0' cellpadding='0' width='100%'><tr><td>"; //henrik here $html .= "<div class='large'><a href='programs.php?action=view_forum.php?forumid=".$row["nForumId"]."' class='link'>".stripslashes($row["cTitle"])."</a></div>\n" ."<div class='normal'>Submitted by : <a href='user_view.php?userid=".$row["nOwnerId"]."'>".stripslashes($row["cOwner"])."</a></div>\n" ."<div class='small'> </div>\n" ."<div class='normal'>".$row["nTopics"]." Review(s), ".$row["nPosts"]." Reviews/Comments, last active <a href='user_view.php?userid=".$row["nLastPostBy"]."'>".stripslashes($row["cLastPoster"])."</a> <br>on ".$row["dLastPost"]." <a href='programs.php?action=view_topic&postid=".$row["nLastPostId"]."#".$row["nLastPostId"]."' title='Read Post'>»</a></div>\n" ."<div class='small'> </div>\n" ."<div class='normal'>".stripslashes($row["cSummary"])."</div>\n"; $html .= "</td><td align='center' valign='bottom' width='150'>"; if ($_SESSION["nexus_userid"]!=""){ $html .= $html_newtopic; } else { $html .= "<div class='normal'><b>Login Required</b><br>You need to login before you can post reviews/comments.</div>\n"; } $html .= "</td></tr></table>\n"; } else { // no forums to list } } else { $html .= "<div class='small'>problem with SQL [".$sql."]</div>\n"; } $html .= "</div></td></tr><tr><td bgcolor='#eeeeee'><div style='padding:5px;'>\n"; $html .= "<div class='large' style='padding-bottom:10px;'>Review : ".$topic_title."</div>\n"; // get the posts in the topic $sql = "SELECT p.nPostId,p.nForumId,p.nTopicId,p.nUserId,u.cUsername,p.cTitle,p.cBody,p.dAdded,p.dEdited,u.nPosts,u.cGender,u.cChatYahoo,u.cChatMSN,u.cChatAIM,u.cChatICQ" ." FROM nexus_ratings p" ." INNER JOIN nexus_users u ON p.nUserId=u.nUserId" ." WHERE nTopicId=".$topicid." ORDER BY nPostId"; $result = mysql_query($sql,$con); if ($result!=false){ $html .= "<table border='0' cellspacing='0' cellpadding='5' width='100%'>"; while ($row =@ mysql_fetch_array($result)){ if ($row["cTitle"]!="") { $title = stripslashes($row["cTitle"]); } else { $title = "... (<i>untitled</i>)"; } $body = stripslashes($row["cBody"]); $username = stripslashes($row["cUsername"]); $userid = stripslashes($row["nUserId"]); $dateadded = stripslashes($row["dEdited"]); $posts = stripslashes($row["nPosts"]); // sort out a thumbnail if (file_exists("pictures/".$row["nUserId"]."t.jpg")){ $picture = "pictures/".$row["nUserId"]."t.jpg"; } else { switch ($row["cGender"]){ case "": $picture = "pictures/no_thumb.jpg"; break; case "m": $picture = "pictures/no_thumb_male.jpg"; break; case "f": $picture = "pictures/no_thumb_female.jpg"; break; } } // prepare the chat icons if ($_SESSION["nexus_userid"]!=""){ if ($row["cChatYahoo"]!="") { $chat_yahoo = "<img src='images/icon_yahoo.png' width='16' height='16' title='".$row["cChatYahoo"]." on Yahoo Messenger'>"; } if ($row["cChatMSN"]!="") { $chat_msn = "<img src='images/icon_msn.png' width='16' height='16' title='".$row["cChatMSN"]." on MSN'>"; } if ($row["cChatAIM"]!="") { $chat_aim = "<img src='images/icon_aim.png' width='16' height='16' title='".$row["cChatAIM"]." on AOL Instant Messenger'>"; } if ($row["cChatICQ"]!="") { $chat_icq = "<img src='images/icon_icq.png' width='16' height='16' title='".$row["cChatICQ"]." on ICQ'>"; } $chat = $chat_yahoo.$chat_msn.$chat_aim.$chat_icq; } else { $chat = "login for more info"; } // prepare the reply html if ($_SESSION["nexus_userid"]!=""){ $html_reply = str_replace("[topicid]",$row["nTopicId"],$html_reply); $html_reply = str_replace("[forumid]",$row["nForumId"],$html_reply); $html_reply = str_replace("[postid]",$row["nPostId"],$html_reply); } else { $html_reply = "<span class='small'>Login to <b>Post Comments</b></span>"; } $html .= "<tr><td><a name='".$row["nPostId"]."'></a>" ."<table width='100%' cellspacing='1' cellpadding='0' border='0' bgcolor='#4A63DE'><tr><td>\n" ."<table width='100%' cellspacing='1' cellpadding='2' border='0' bgcolor='#ffffff'>\n" ."<tr>" ."<td valign='top' align='center' width='120' bgcolor='#ffffff'>" ."<div style='padding:5px;'>\n" ."<div align='center'><img src='".$picture."' width='64' height='64' border='1'></div>\n" ."<div align='center' class='normal'><br><a href='user_view.php?userid=".$userid."'><b>".$username."</b></a></div>\n" ."<div align='center' class='small' style='padding:2px;'>".$chat." <b>".$posts."</b></div>\n" ."<div align='center' class='small'><b>reviews/comments</b></div>\n" ."</div>\n" ."</td>\n" ."<td bgcolor='#ffffff' class='normal'>" ."<div class='normal' style='padding:10px;'><b>".prepare($title)."</b></div>" ."<div class='normal' style='padding:20px;'>".prepare($body)."</div>" ."<div class='small' style='padding:1px;border-top:1px solid #ccc;text-align:right;'>Posted by <a href='user_view.php?userid=".$userid."'>".$username."</a> on ".$dateadded.". ".$html_reply."</div>\n" ."</td></tr>\n" ."</table>\n" ."</td></tr></table>\n" ."</td></tr>\n"; } $html .= "</table>\n"; } else { $html .= "<p align='center' class='small'>Problem with the SQL [".$sql."]</p>\n"; } $html .= "</div></td></tr></table>\n"; } else { // no such topic } } else { // problem with SQL } }// if action is 'new_topic' show the entry formif ($_GET["action"]=="new_topic"){ if ($_SESSION["nexus_userid"]!="" && $_SESSION["nexus_enabled"]!=""){ // show the form for a new topic $html .= "<form method='POST' action='programs_exec.php?action=new_topic'>\n" ."<input type='hidden' name='forumid' value='".$_GET["forumid"]."'>\n" ."<table border='0' cellspacing='1' cellpadding='2' bgcolor='#4A63DE'>\n" ."<tr><td bgcolor='#4A63DE' class='small'> <font color='#ffffff'>Post Your Review</font></td></tr>\n" ."<tr><td bgcolor='#ffffff' class='small'>Title</td><td bgcolor='#ffffff'><input name='title' type='text' class='text' size='70'></td></tr>\n" ."<tr><td bgcolor='#ffffff' class='small'>Body</td><td bgcolor='#ffffff'><textarea name='body' class='text' cols='80' rows='15'></textarea></td></tr>\n" ."<tr><td bgcolor='#ffffff' align='right' colspan='2'><input type='submit' value='Post Your Review'></td></tr>\n" ."</table>\n" ."</form>\n"; } else { $html .= "<p class='title'>Login Required</p>\n" ."<p class='normal'>You are trying to access a section of the site that requires a login. Use the form on the left to login - you will then be taken to the page you were trying to access.</p>\n" ."<p class='normal'>If you get stuck, email <a href='mailto:".$admin_email."'>".$admin_email."</a> for assistance.</p>\n"; } }// if action is 'reply' show the reply formif ($_GET["action"]=="reply"){ if ($_SESSION["nexus_userid"]!="" && $_SESSION["nexus_enabled"]!=""){ $forumid = $_GET["forumid"]; $topicid = $_GET["topicid"]; $postid = $_GET["postid"]; // get data of the message we are replying to $con = db_connect(); $sql = "SELECT p.cTitle,p.cBody,p.dAdded,p.dEdited,u.cUsername,p.nUserId" ." FROM nexus_ratings p" ." INNER JOIN nexus_users u ON p.nUserId=u.nUserId" ." WHERE p.nPostId=".$postid; $result = mysql_query($sql,$con); if ($result!=false){ if (mysql_num_rows($result)>0){ $row = mysql_fetch_array($result); // show the message they are replying to $html .= "<table border='0' cellspacing='1' cellpadding='2' bgcolor='#4A63DE'>\n" ."<tr><td class='small' bgcolor='#4A63DE'><font color='#ffffff'>Reply to this message by ".stripslashes($row["cUsername"]).", written on ".$row["dAdded"]."</font></td></tr>\n" ."<tr><td class='small' bgcolor='#ffffff'><div style='padding:10px;'><b>".stripslashes($row["cTitle"])."</b><br><br>".prepare(stripslashes($row["cBody"]))."</div></td></tr>\n" ."</table>\n"; $html .= "<br>\n"; // prepare a title $title = stripslashes($row["cTitle"]); if ($title==""){ $title = "untitled"; } $title = str_replace("re: ","",$title); $title = "re: ".$title; // show the form for a reply to a topic $html .= "<form method='POST' action='programs_exec.php?action=reply'>\n" ."<input type='hidden' name='forumid' value='".$_GET["forumid"]."'>\n" ."<input type='hidden' name='topicid' value='".$_GET["topicid"]."'>\n" ."<input type='hidden' name='parentid' value='".$_GET["postid"]."'>\n" ."<table border='0' cellspacing='1' cellpadding='2' bgcolor='#4A63DE'>\n" ."<tr><td bgcolor='#4A63DE' class='small'> <font color='#ffffff'><b>Post Comments</b></font></td></tr>\n" ."<tr><td bgcolor='#ffffff' class='small'>Title</td><td bgcolor='#ffffff'><input name='title' type='text' class='text' size='70' value='".$title."'></td></tr>\n" ."<tr><td bgcolor='#ffffff' class='small'>Body</td><td bgcolor='#ffffff'><textarea name='body' class='text' cols='80' rows='15'></textarea></td></tr>\n" ."<tr><td bgcolor='#ffffff' align='right' colspan='2'><input type='submit' value='Post Comments'></td></tr>\n" ."</table>\n" ."</form>\n"; } else { $html .= "<div class='small'>No Post exists with that ID</div>\n"; } } else { $html .= "<p align='center' class='small'>Problem with the SQL [".$sql."]</p>\n"; } } else { // enabled account required $html .= "<p class='title'>Login Required</p>\n" ."<p class='normal'>You are trying to access a section of the site that requires a login. Use the form on the left to login - you will then be taken to the page you were trying to access.</p>\n" ."<p class='normal'>If you get stuck, email <a href='mailto:".$admin_email."'>".$admin_email."</a> for assistance.</p>\n"; }}$html .= html_page_end();print $html;?>
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...