oneday Posted April 17, 2007 Share Posted April 17, 2007 Hi, I'm looking to create a part of a website where people can fill out a simple form to post a comment on the page. A good example of what I'm looking for can be found at http://malfunctionjunction.net/?p=350#postcomment Can anyone direct me to a tutorial where they can teach me how I could do this? Thanks Link to comment https://forums.phpfreaks.com/topic/47406-posting-comments/ Share on other sites More sharing options...
boo_lolly Posted April 17, 2007 Share Posted April 17, 2007 this is pretty easy, will you be using a database or a flat-file? Link to comment https://forums.phpfreaks.com/topic/47406-posting-comments/#findComment-231331 Share on other sites More sharing options...
Cheeseweasel Posted April 17, 2007 Share Posted April 17, 2007 I'd also like to know this, and although I'm hijacking a thread here, in my case a flat file would be better. Link to comment https://forums.phpfreaks.com/topic/47406-posting-comments/#findComment-231355 Share on other sites More sharing options...
Anzeo Posted April 17, 2007 Share Posted April 17, 2007 Well, let Oneday decide first and we'll work out flat files later ^^ Link to comment https://forums.phpfreaks.com/topic/47406-posting-comments/#findComment-231361 Share on other sites More sharing options...
oneday Posted April 17, 2007 Author Share Posted April 17, 2007 Im going to be using a mySQL Database Link to comment https://forums.phpfreaks.com/topic/47406-posting-comments/#findComment-231385 Share on other sites More sharing options...
Cheeseweasel Posted April 17, 2007 Share Posted April 17, 2007 Grrr... ...just kidding. Link to comment https://forums.phpfreaks.com/topic/47406-posting-comments/#findComment-231389 Share on other sites More sharing options...
Anzeo Posted April 17, 2007 Share Posted April 17, 2007 well, do you want users to comment on specific newspost or do you want a general place where they can drop a note (like a guestbook) ? Link to comment https://forums.phpfreaks.com/topic/47406-posting-comments/#findComment-231394 Share on other sites More sharing options...
oneday Posted April 17, 2007 Author Share Posted April 17, 2007 I want it for a specific post, so if I put something up they can post a reply that is limited to that page. Link to comment https://forums.phpfreaks.com/topic/47406-posting-comments/#findComment-231414 Share on other sites More sharing options...
Anzeo Posted April 17, 2007 Share Posted April 17, 2007 Okay then you'll need two tables one table will contain your posts and the other will contain the replies. I suggest you name your post table TOPIC and add at least the following attributs: ID,Title,Message,Author,Date now make your POST table (to hold the replies) and add at least the following attributes: ID,Message,Author,Date,Topic Now the Topic attribute in your POST table will need to hold the ID from a topic in the TOPIC table this can be obtained by adding the id of the topic to your "add reply" link. the link should look like http://yourdomain.com/addreply.php?topic=$topic where your $topic is the id of the topic you're watching. Now you simply add this $topic to your POST table when adding a reply. Link to comment https://forums.phpfreaks.com/topic/47406-posting-comments/#findComment-231425 Share on other sites More sharing options...
boo_lolly Posted April 17, 2007 Share Posted April 17, 2007 Okay then you'll need two tables you only need one table... first, create a table in your database and call it 'threads_and_posts'. i'd have columns like this: +-------------------------------------------------------------+ | threads_and_posts | +------+---------------+---------+--------------+------+------+ | id | thread_id | name | thread_title | post | date | +------+---------------+---------+--------------+------+------+ set id to AUTO INCRIMENT. then, create a page where a user can start a new thread: <?php //addthread.php /*if user submitted new thread*/ if(isset($_POST)){ /*connect to database*/ $db = mysql_connect('xxx', 'xxx', 'xxx'); ((!$db) ? ("Error: Could not connect to the database.\n") : ("")); /*select database*/ mysql_select_db('database_name', $db); /*insert new thread*/ $sql = " INSERT INTO threads_and_posts (name, thread_title, post, date) VALUES( '". $_POST['name'] ."', '". $_POST['thread_title'] ."', '". $_POST['post'] ."', '". date() ."' ) "; /*execute query*/ mysql_query($sql); echo "Your thread has been added to the database successfully.\n"; } /*print for for user to post to this thread*/ echo " <form action=\"\" method=\"post\"> Thread Title: <input type=\"text\" name=\"thread_title\"> Your Name: <input type=\"text\" name=\"name\"> Post: <textarea cols=\"40\" rows=\"5\" name=\"post\"> <input type=\"submit\" value=\"Submit Post\"> </form> \n"; ?> then, create a page that displays all the threads in the order of which thread has the newest post, and have each thread name link to a page that will dynamically display the posts under a particular thread. <?php //showthreads.php /*connect to database*/ $db = mysql_connect('xxx', 'xxx', 'xxx'); ((!$db) ? ("Error: Could not connect to the database.\n") : ("")); /*select database*/ mysql_select_db('database_name', $db); /*pull all threads*/ $sql = " SELECT * FROM threads_and_posts GROUP BY thread_id ORDER BY date DESC "; $query = mysql_query($sql) OR die(mysql_error()); /*populate table*/ echo "<table border=\"1\">\n"; while($row = mysql_fetch_array($query)){ echo "<tr><td><a href=\"thread.php?id={$row['thread_id']}\">{$row['thread_title']}</a></td><td>{$row['date']}</td></tr>\n"; } echo "</table>\n"; ?> then, create a page that will display all the posts within a specific thread: <?php //thread.php /*if user submitted new post*/ if(isset($_POST)){ /*connect to database*/ $db = mysql_connect('xxx', 'xxx', 'xxx'); ((!$db) ? ("Error: Could not connect to the database.\n") : ("")); /*select database*/ mysql_select_db('database_name', $db); /*insert new post*/ $sql = " INSERT INTO threads_and_posts (thread_id, name, post, date) VALUES( '". $_GET['id'] ."', '". $_POST['name'] ."', '". $_POST['post'] ."', '". date() ."' ) "; /*execute query*/ mysql_query($sql); echo "Your thread has been added to the database successfully.\n"; } /*connect to database*/ $db = mysql_connect('xxx', 'xxx', 'xxx'); ((!$db) ? ("Error: Could not connect to the database.\n") : ("")); /*select database*/ mysql_select_db('database_name', $db); /*pull all posts*/ $sql = " SELECT * FROM threads_and_posts WHERE thread_id = '". $_GET['id'] ." ORDER BY date DESC "; $query = mysql_query($sql) OR die(mysql_error()); /*populate table*/ echo "<table border=\"1\">\n"; while($row = mysql_fetch_array($query)){ echo "<tr><td>{$row['name']}</td><td>{$row['date']}</td></tr>"; echo "<tr><td colspan=\"2\">{$row['post']}</td></tr>\n"; } echo "</table>\n"; /*print for for user to post to this thread*/ echo " <form action=\"\" method=\"post\"> Your Name: <input type=\"text\" name=\"name\"> Post: <textarea cols=\"40\" rows=\"5\" name=\"post\"> <input type=\"submit\" value=\"Submit Post\"> </form> \n"; /*print link to go back to threads*/ echo "<a href=\"showthreads.php\">Back to Threads</a>\n"; ?> that should explain a few things. Link to comment https://forums.phpfreaks.com/topic/47406-posting-comments/#findComment-231471 Share on other sites More sharing options...
oneday Posted April 17, 2007 Author Share Posted April 17, 2007 Thats very helpful guys, thx. Boo, I was thinking to have them all on the same page though, not like a thread. More like: My Post Comments: Name: ______ Date: ________ Comment: ________ ________________________ Name: ______ Date: ________ Comment: ________ ________________________ Name: ______ Date: ________ Comment: ________ Post your own comment: Form Link to comment https://forums.phpfreaks.com/topic/47406-posting-comments/#findComment-231477 Share on other sites More sharing options...
boo_lolly Posted April 17, 2007 Share Posted April 17, 2007 well my examples provided more than enough illustrations and descriptions for you to be able to do what you need to do specifically. in fact, i've done more than what you need. all you need to do is break it down. Link to comment https://forums.phpfreaks.com/topic/47406-posting-comments/#findComment-231481 Share on other sites More sharing options...
oneday Posted April 17, 2007 Author Share Posted April 17, 2007 I will, thank you. Link to comment https://forums.phpfreaks.com/topic/47406-posting-comments/#findComment-231487 Share on other sites More sharing options...
boo_lolly Posted April 17, 2007 Share Posted April 17, 2007 after you've attempted to work with the code i've provided, let us know if you have trouble, and post your variation of code. Link to comment https://forums.phpfreaks.com/topic/47406-posting-comments/#findComment-231499 Share on other sites More sharing options...
oneday Posted April 25, 2007 Author Share Posted April 25, 2007 Ok, sorry it took so long for me to get caught up on this, but I've been really busy. I wanna mention that this is the first php coding I'll be implementing in any website i've done. Anyways... first, create a table in your database and call it 'threads_and_posts'. i'd have columns like this: +-------------------------------------------------------------+ | threads_and_posts | +------+---------------+---------+--------------+------+------+ | id | thread_id | name | thread_title | post | date | +------+---------------+---------+--------------+------+------+ set id to AUTO INCRIMENT. How do I make this table? Is it made in html or something else? Link to comment https://forums.phpfreaks.com/topic/47406-posting-comments/#findComment-238330 Share on other sites More sharing options...
Anzeo Posted April 25, 2007 Share Posted April 25, 2007 It's a database table. I assume your host provides php and mysql and that they are installed? If not you probably want to install mysql for convenience. Also, I suggest a basic tutorial in sql to understand databases. Link to comment https://forums.phpfreaks.com/topic/47406-posting-comments/#findComment-238339 Share on other sites More sharing options...
oneday Posted April 25, 2007 Author Share Posted April 25, 2007 Im just looking it up now Link to comment https://forums.phpfreaks.com/topic/47406-posting-comments/#findComment-238341 Share on other sites More sharing options...
leela Posted April 25, 2007 Share Posted April 25, 2007 Hai, Can anyone send me and database Queries regarding MYSQL .I will try to solve as i was a fresher to Mysql. Link to comment https://forums.phpfreaks.com/topic/47406-posting-comments/#findComment-238380 Share on other sites More sharing options...
Anzeo Posted April 25, 2007 Share Posted April 25, 2007 I'm sorry, what? Link to comment https://forums.phpfreaks.com/topic/47406-posting-comments/#findComment-238385 Share on other sites More sharing options...
leela Posted May 5, 2007 Share Posted May 5, 2007 Nothing just i want the questions like " select names from table_name where id=1"???? or similar questions in MYSQL. Thanks, Leela Link to comment https://forums.phpfreaks.com/topic/47406-posting-comments/#findComment-246198 Share on other sites More sharing options...
leela Posted May 5, 2007 Share Posted May 5, 2007 Sir, i want to have minimum of 300 characters in text area and the characters count should be displayed below the textarea ( using innerHTML or anything else ) .if character are less than 300 , an error message shud be displayed. how to convert bmp to jpeg format ? will "........imagebwmp...." work?? Thanks Leela Link to comment https://forums.phpfreaks.com/topic/47406-posting-comments/#findComment-246214 Share on other sites More sharing options...
boo_lolly Posted May 7, 2007 Share Posted May 7, 2007 Sir, i want to have minimum of 300 characters in text area and the characters count should be displayed below the textarea ( using innerHTML or anything else ) .if character are less than 300 , an error message shud be displayed. this is done with a client-side language such as javascript. how to convert bmp to jpeg format ? will "........imagebwmp...." work?? Thanks Leela this is another thread. Link to comment https://forums.phpfreaks.com/topic/47406-posting-comments/#findComment-247010 Share on other sites More sharing options...
leela Posted June 26, 2007 Share Posted June 26, 2007 <? session_start(); ob_start(); //print_r($_POST); $_SESSION['showphoto']=$_POST['showphoto']; $p=$_SESSION['showphoto']; if($_SESSION['s_username']=="") { header("location:index.php"); } include("includes/connectdb.php"); include_once("includes/DbSql.inc.php"); include("class/cls_tpl.php"); include("includes/PicSql.inc.php"); include_once("includes/pager.php"); include_once("includes/dist.php"); //include("class/img_function.php"); $htmlpage="html"; $db =new PicSQL ($DB_NAME); $err = new clstpl('error'); $ob=new distance(); $acts="profile"; if(isset($_GET['action'])) { $acts=$_GET['action']; } elseif(isset($_POST['action'])) { $acts=$_POST['action']; } if($acts=="profile" ) { //$act_title="My Profile"; $imge="myprofile"; } if($acts=="online") { $act_title="Who's Online"; $imge="whosonline"; } if($acts=="latest") { $act_title="Latest Members"; $imge="lastmember"; } if($acts=="fav") { $act_title="My HotList"; $imge="myhotlists"; } if($acts=="search") { $act_title="Quick Search"; $imge="searchprofile"; } if($acts=="profile") { $tpl=new clstpl($htmlpage."/u_profile.html","$lang"); } else if($acts=="search") { $tpl=new clstpl($htmlpage."/s_members.html","$lang"); } else { $tpl=new clstpl($htmlpage."/profile.html","$lang"); } if($acts!="profile" &&(!isset($_GET['userid']))) { $_SESSION['prev_page']="profile.php?action=".$acts; } ob_start(); include("left_section.php"); $left_section=ob_get_contents(); ob_end_clean(); ob_start(); include("menu_profile.php"); $menu_profile=ob_get_contents(); ob_end_clean(); $tpl->adddata("_left_section__",$left_section); $tpl->adddata("_menu_profile__",$menu_profile); $sessid=$_SESSION['s_userid']; if($_GET['remove_userid']!="") { $sessid=$_SESSION['s_userid']; $rm=$_GET['remove_userid']; $del_sql="delete from favorite_members where userid='$sessid' and fav_userid='$rm'"; $del_rs=$db->delete_data($del_sql); header("location:profile.php?userid=$rm"); } if($_GET['add_userid']!="") { $sessid=$_SESSION['s_userid']; $add=$_GET['add_userid']; $ins_sql="insert into favorite_members(userid,fav_userid) values('$sessid','$add')"; $rs_sql=$db->insert_data($ins_sql); header("location:profile.php?action=fav&userid=$add"); } $tpl->adddata("#(act_title)#", $act_title); $tpl->adddata("#(type)#",$imge); $tpl->adddata("#(prev_page)#", $_SESSION['prev_page']); $sessid=$_SESSION['s_userid']; $user=$db->get_field('user',user_name,userid,$sessid); $pass=$db->get_field('user',pass,userid,$sessid); $tpl->adddata("#(user)#",$user); $tpl->adddata("#(pass)#",$pass); $tpl->adddata("#(sort_dip)#","none"); if($_GET['userid']=="") $uid=$_SESSION['s_userid']; else $uid=$_GET['userid']; /*if($db->profile_suspended($uid)==1) { //header("location:inactive_members.php"); } */ //find whether in favorites $sel_fav="select * from favorite_members where userid='$sessid' and fav_userid='$uid'"; $rs_fav=$db->select_data($sel_fav); if(count($rs_fav)>0) { $tpl->adddata("#(st_comm)#",""); $tpl->adddata("#(end_comm)#",""); $tpl->adddata("#(s_c)#","<!--"); $tpl->adddata("#(e_c)#","-->"); } else { $tpl->adddata("#(st_comm)#","<!--"); $tpl->adddata("#(end_comm)#","-->"); $tpl->adddata("#(s_c)#",""); $tpl->adddata("#(e_c)#",""); } //insert to profile_hits if($uid!=$_SESSION['s_userid']) { $tm=time(); $ins_hits="insert into profile_hits(userid,hit_time) values('$uid','$tm')"; $rs_hits=$db->insert_data($ins_hits); }//end if($uid!=$_SESSION['s_userid']) //show rate status $sel_game="select * from rate_game where game_status=1"; $rs_game=$db->select_data($sel_game); $gid=$rs_game[0][rategameid]; $find_mem="select * from rate_game_members where rategameid=$gid and userid=$uid"; $rs_mem=$db->select_data($find_mem); if(count($rs_mem)>0 && $uid==$_SESSION['s_userid']) { $sessid=$_SESSION['s_userid']; $full=$db->get_field('user',full_member,userid,$sessid); if($full==0) { $tpl->adddata("#(START_COMM)#",""); $tpl->adddata("#(END_COMM)#",""); } else { $tpl->adddata("#(START_COMM)#","<!--"); $tpl->adddata("#(END_COMM)#","-->"); } } else { $tpl->adddata("#(START_COMM)#","<!--"); $tpl->adddata("#(END_COMM)#","-->"); } //-----------------------------------show rating status------------------------------- $to_id=$uid; if($acts=='fav' || $acts=='online' || $acts=='latest' || $acts=='search' || isset($_POST['searching']) || isset($_POST['searching2']) || $acts=='searched')// modification for distance { if((isset($_POST['distance']) && $_POST['distance']!='')) $select_distance = $_POST['distance']; else if(isset($_GET['distance'])) $select_distance = $_GET['distance']; else $select_distance = 50; $sel_distance="select id,distance from master_fields"; $rs_distance=$db->select_data($sel_distance); $row=$tpl->gethtmlcode("distance"); for($i=0;$i<count($rs_distance);$i++) { if($rs_distance[$i][distance]!="") { $newrow=$row; if($rs_distance[$i][distance]==$select_distance) { if($select_distance==-1) $newrow=$tpl->replacedata($newrow,"#(distance)#","<option value=".$rs_distance[$i]['distance']." selected> All </option>"); else $newrow=$tpl->replacedata($newrow,"#(distance)#","<option value=".$rs_distance[$i]['distance']." selected>".$rs_distance[$i]['distance']. miles."</option>"); } else if($distance==$rs_distance[$i][distance]) { $newrow=$tpl->replacedata($newrow,"#(distance)#","<option value=".$rs_distance[$i]['distance'].">".$rs_distance[$i]['distance']. miles."</option>"); } else if($rs_distance[$i]['distance']!=0 && $rs_distance[$i]['distance']!=-1) { $newrow=$tpl->replacedata($newrow,"#(distance)#","<option value=".$rs_distance[$i]['distance'].">".$rs_distance[$i]['distance']. miles."</option>"); } else if($rs_distance[$i]['distance']==-1 || $select_distance==-1) { $newrow=$tpl->replacedata($newrow,"#(distance)#","<option value=".$rs_distance[$i]['distance']."> All </option>"); } $tpl->appenddata("distance",$newrow); }//if }//for }// if if(($_POST['showphoto'] != '' && isset($_POST['showphoto'])) || (isset($_GET['showphoto']) && $_GET['showphoto']==1)) { $checked=' <input type="checkbox" name="showphoto" id="showphoto" onClick="javascript: show_photo();" checked/>'; $pho = 1; $tpl->adddata("#(check_box)#",$checked); } else { $checked=' <input type="checkbox" name="showphoto" id="showphoto" onClick="javascript: show_photo();" />'; $pho=0; $tpl->adddata("#(check_box)#",$checked); } if($acts=="search") { $row=$tpl->gethtmlcode("fromagerow"); for($i=18;$i<=99;$i++) { $newrow=$row; if($i==18) $newrow=$tpl->replacedata($newrow,"#(FROMAGE_COMBO)#","<option value=".$i." selected>".$i."</option>"); else $newrow=$tpl->replacedata($newrow,"#(FROMAGE_COMBO)#","<option value=".$i.">".$i."</option>"); $tpl->appenddata("fromagerow",$newrow); }//end for //for toage combo $row=$tpl->gethtmlcode("toagerow"); for($i=18;$i<=99;$i++) { $newrow=$row; if($i==99) $newrow=$tpl->replacedata($newrow,"#(TOAGE_COMBO)#","<option value=".$i." selected>".$i."</option>"); else $newrow=$tpl->replacedata($newrow,"#(TOAGE_COMBO)#","<option value=".$i.">".$i."</option>"); $tpl->appenddata("toagerow",$newrow); }//end for //for gender $sel_gender="select id,gender from master_fields"; $rs_gender=$db->select_data($sel_gender); $row=$tpl->gethtmlcode("gender_from"); for($i=0;$i<count($rs_gender);$i++) { if($rs_gender[$i][gender]!="") { $newrow=$row; $newrow=$tpl->replacedata($newrow,"#(gender_from)#","<option value=".$rs_gender[$i][id].">".$rs_gender[$i][gender]."</option>"); $tpl->appenddata("gender_from",$newrow); } }//end for //for height_to combo $row=$tpl->gethtmlcode("gender"); for($i=count($rs_gender);$i>=0;$i--) { if($rs_gender[$i][gender]!="") { $newrow=$row; $newrow=$tpl->replacedata($newrow,"#(gender)#","<option value=".$rs_gender[$i][id].">".$rs_gender[$i][gender]."</option>"); $tpl->appenddata("gender",$newrow); } }//end for //========end for gender $sel_height="select id,height from master_fields where height!=''"; $rs_height=$db->select_data($sel_height); $row=$tpl->gethtmlcode("height_from"); $newrow=$row; $newrow=$tpl->replacedata($newrow,"#(height_from)#","<option value=".$rs_height[$i][id].">".Any."</option>"); $tpl->appenddata("height_from",$newrow); for($i=0;$i<count($rs_height);$i++) { if($rs_height[$i][height]!="") { $newrow=$row; $newrow=$tpl->replacedata($newrow,"#(height_from)#","<option value=".$rs_height[$i][id].">".$rs_height[$i][height]."</option>"); $tpl->appenddata("height_from",$newrow); } }//end for //for height_to combo $sel_height="select id,height from master_fields where height!=''"; $rs_height=$db->select_data($sel_height); $row=$tpl->gethtmlcode("height_to"); for($i=count($rs_height);$i>0;$i--) { if($rs_height[$i][height]!="") { $newrow=$row; $newrow=$tpl->replacedata($newrow,"#(height_to)#","<option value=".$rs_height[$i][id].">".$rs_height[$i][height]."</option>"); $tpl->appenddata("height_to",$newrow); } }//end for //for body combo $sel_body="select body_type from master_fields order by body_type"; $rs_body=$db->select_data($sel_body); $row=$tpl->gethtmlcode("body_row"); $newrow=$row; $newrow=$tpl->replacedata($newrow,"#(body)#","<table width='100%' class=\"content\"><tr>"); $tpl->appenddata("body_row",$newrow); $j=1; $newrow=$row; $newrow=$tpl->replacedata($newrow,"#(body)#","<td><input type='checkbox'></td><td name='body_arr[]' value='any'>Any</input></td>"); $tpl->appenddata("body_row",$newrow); for($i=1;$i<=count($rs_body);$i++) { if($rs_body[$i][body_type]!="") { $newrow=$row; $newrow=$tpl->replacedata($newrow,"#(body)#","<td><input type='checkbox'></td><td name='body_arr[]' value=".$rs_body[$i][body_type].">".$rs_body[$i][body_type]."</input></td>"); $tpl->appenddata("body_row",$newrow); $j++; if($j%4 == 0) { $newrow=$row; $newrow=$tpl->replacedata($newrow,"#(body)#","</tr><tr>"); $tpl->appenddata("body_row",$newrow); } } }//end for $newrow=$row; $newrow=$tpl->replacedata($newrow,"#(body)#","</tr></table>"); $tpl->appenddata("body_row",$newrow); // for active $sel_active="select id,active from master_fields"; $rs_active=$db->select_data($sel_active); $row=$tpl->gethtmlcode("active"); for($i=0;$i<count($rs_active);$i++) { if($rs_active[$i][active]!="") { $newrow=$row; $newrow=$tpl->replacedata($newrow,"#(active)#","<option value=".$rs_active[$i][id].">".$rs_active[$i][active]."</option>"); $tpl->appenddata("active",$newrow); } }//end for //for eyecolor combo $sel_eye="select eye_color from master_fields order by eye_color"; $rs_eye=$db->select_data($sel_eye); $row=$tpl->gethtmlcode("eye_row"); $newrow=$row; $newrow=$tpl->replacedata($newrow,"#(eye)#","<table width='100%' class='content'><tr>"); $tpl->appenddata("eye_row",$newrow); $j=1; $newrow=$row; $newrow=$tpl->replacedata($newrow,"#(eye)#","<td><input type='checkbox'></td><td name='eye_arr[]' value='any'>Any</input></td>"); $tpl->appenddata("eye_row",$newrow); for($i=1;$i<=count($rs_eye);$i++) { if($rs_eye[$i][eye_color]!="") { $newrow=$row; $newrow=$tpl->replacedata($newrow,"#(eye)#","<td><input type='checkbox'></td><td name='eye_arr[]' value=".$rs_eye[$i][eye_color].">".$rs_eye[$i][eye_color]."</input></td>"); $tpl->appenddata("eye_row",$newrow); $j++; if($j%4 == 0) { $newrow=$row; $newrow=$tpl->replacedata($newrow,"#(eye)#","</tr><tr>"); $tpl->appenddata("eye_row",$newrow); } } }//end for $newrow=$row; $newrow=$tpl->replacedata($newrow,"#(eye)#","</tr></table>"); $tpl->appenddata("eye_row",$newrow); //end for //for haircolor combo $sel_hair="select hair_color from master_fields order by hair_color"; $rs_hair=$db->select_data($sel_hair); $row=$tpl->gethtmlcode("hair_row"); $newrow=$row; $newrow=$tpl->replacedata($newrow,"#(hair)#","<table width='100%' class='content'><tr>"); $tpl->appenddata("hair_row",$newrow); $j=1; $newrow=$row; $newrow=$tpl->replacedata($newrow,"#(hair)#","<td><input type='checkbox'></td><td name='hair_arr[]' value='any'>Any</input></td>"); $tpl->appenddata("hair_row",$newrow); for($i=1;$i<=count($rs_hair);$i++) { if($rs_hair[$i][hair_color]!="") { $newrow=$row; $newrow=$tpl->replacedata($newrow,"#(hair)#","<td><input type='checkbox'></td><td name='hair_arr[]' value=".$rs_hair[$i][hair_color].">".$rs_hair[$i][hair_color]."</input></td>"); $tpl->appenddata("hair_row",$newrow); $j++; if($j%4 == 0) { $newrow=$row; $newrow=$tpl->replacedata($newrow,"#(hair)#","</tr><tr>"); $tpl->appenddata("hair_row",$newrow); } } }//end for $newrow=$row; $newrow=$tpl->replacedata($newrow,"#(hair)#","</tr></table>"); $tpl->appenddata("hair_row",$newrow); //end for Link to comment https://forums.phpfreaks.com/topic/47406-posting-comments/#findComment-282728 Share on other sites More sharing options...
leela Posted June 26, 2007 Share Posted June 26, 2007 // for ethinicity $sel_ethinicity="select ethinicity from master_fields order by ethinicity"; $rs_ethinicity=$db->select_data($sel_ethinicity); $row=$tpl->gethtmlcode("ethinicity"); $newrow=$row; $newrow=$tpl->replacedata($newrow,"#(ethinicity)#","<table width='100%' class='content'><tr>"); $tpl->appenddata("ethinicity",$newrow); $j=1; $newrow=$row; $newrow=$tpl->replacedata($newrow,"#(ethinicity)#","<td><input type='checkbox'></td><td name='ethinicity_arr[]' value='any'>Any</input></td>"); $tpl->appenddata("ethinicity",$newrow); for($i=1;$i<=count($rs_ethinicity);$i++) { if($rs_ethinicity[$i][ethinicity]!="") { $newrow=$row; $newrow=$tpl->replacedata($newrow,"#(ethinicity)#","<td><input type='checkbox'><td name='ethinicity_arr[]' value=".$rs_ethinicity[$i][ethinicity].">".$rs_ethinicity[$i][ethinicity]."</input></td>"); $tpl->appenddata("ethinicity",$newrow); $j++; if($j%4 == 0) { $newrow=$row; $newrow=$tpl->replacedata($newrow,"#(ethinicity)#","</tr><tr>"); $tpl->appenddata("ethinicity",$newrow); } } }//end for $newrow=$row; $newrow=$tpl->replacedata($newrow,"#(ethinicity)#","</tr></table>"); $tpl->appenddata("ethinicity",$newrow); //end for // for occupation $sel_occupation="select id,occupation from master_fields"; $rs_occupation=$db->select_data($sel_occupation); $row=$tpl->gethtmlcode("occupation"); for($i=0;$i<count($rs_occupation);$i++) { if($rs_occupation[$i][occupation]!="") { $newrow=$row; $newrow=$tpl->replacedata($newrow,"#(occupation)#","<option value=".$rs_occupation[$i][id].">".$rs_occupation[$i][occupation]."</option>"); $tpl->appenddata("occupation",$newrow); } } //for country /* $sel_country = "select * from mwm_mas_country order by country_name"; $rs_country = $db->select_data($sel_country); $row=$tpl->gethtmlcode("country"); for($h=0;$h<count($rs_country);$h++) { $newrow=$row; if($_POST['country']==$rs_country[$h][country_name]) $newrow=$tpl->replacedata($newrow,"#(country_sel)#","selected"); $newrow=$tpl->replacedata($newrow,"#(country)#",$rs_country[$h][country_name]); $tpl->appenddata("country",$newrow); } */ $sel_country = "select country_code,country_name from mwm_mas_country order by country_name"; $rs_country = $db->select_data($sel_country); $row=$tpl->gethtmlcode("country"); for($h=0;$h<count($rs_country);$h++) { $newrow=$row; if($_REQUEST['country']==$rs_country[$h][country_name]) $newrow=$tpl->replacedata($newrow,"#(country)#","selected"); else if($rs_country[$h][country_code]=='US') { $newrow=$tpl->replacedata($newrow,"#(country)#","<option value=".$rs_country[$h][country_code]." selected>".$rs_country[$h][country_name]."</option>"); } else $newrow=$tpl->replacedata($newrow,"#(country)#",$rs_country[$h][country_name]); $tpl->appenddata("country",$newrow); } if($_REQUEST['country']!="") $_SESSION['country_sel'] = $_REQUEST['country']; //to display states /* $getst = "select state_code,state_name from mwm_mas_state order by state_name"; $rs_state=$db->select_data($getst); $row=$tpl->gethtmlcode("state"); for($h=0;$h<count($rs_state);$h++) { $newrow=$row; if($_POST['state']==$rs_state[$h][state_code]){ $newrow=$tpl->replacedata($newrow,"#(state)#","<option value=".$rs_state[$h][state_code]." selected>".$rs_state[$h][state_name]."</option>"); }else { //$newrow=$tpl->replacedata($newrow,"#(state_sel)#","state"); // $newrow=$tpl->replacedata($newrow,"#(state)#",$rs_state[$h][state_code]); $newrow=$tpl->replacedata($newrow,"#(state)#","<option value=".$rs_state[$h][state_code].">".$rs_state[$h][state_name]."</option>"); } $tpl->appenddata("state",$newrow); } if($_POST['state']!='') $_SESSION['state_code']=$_POST['state']; $val1=$_POST['state_code']; */ if($_REQUEST[country]=='US' || !isset($_REQUEST[country])) { $s = " <select name=\"state\" size=\"1\" class=\"box_black\" id=\"state\" style=\"width:190px\"> <option value=\"\" >Select State</option>"; $getst = "select state_code,state_name from mwm_mas_state order by state_name"; $rs_state=$db->select_data($getst); for($i=0;$i<count($rs_state);$i++) { if(isset($_REQUEST['state']) && ($_REQUEST['state'] == $rs_state[$i]['state_name'])) $s .= "<option value=\"".$rs_state[$i]['state_name']."\" selected>".$rs_state[$i]['state_name']."</option>"; else $s .= "<option value=\"".$rs_state[$i]['state_name']."\">".$rs_state[$i]['state_name']."</option>"; }//for $s .= "</select>"; } $tpl->adddata("#(s)#",$s); // for photo $sel_photo="select pThum,pBig from userphoto where userid='$userid' and pMain='1' and ( pThum!='nophoto.jpg' or pBig!='nophoto.jpg') "; $rs_photo=$db->select_data($sel_photo); $n=1; $row=$tpl->gethtmlcode("showphoto"); for($h=0;$h<count($rs_photo);$h++) { $res=$db->getUserPhoto($userid,$type="T"); $res=$tpl->replacedata($res,'#(showphoto)#',$n++); $tpl->appenddata("showphoto",$res); } }//end of search action Link to comment https://forums.phpfreaks.com/topic/47406-posting-comments/#findComment-282731 Share on other sites More sharing options...
leela Posted June 26, 2007 Share Posted June 26, 2007 if($acts!="profile" && $acts!="search") { $row34=$tpl->gethtmlcode("show_profiles"); $view1=""; $view2=""; $view3=""; $sex1=""; $sex2=""; $sex3=""; if(($_POST['showphoto'] != '' && isset($_POST['showphoto'])) || (isset($_GET['showphoto']) && $_GET['showphoto']==1)) { $query12="SELECT u.*,p.pThum as photo_path,c.latitude,c.longitude FROM user u,userphoto p,mwm_mas_city c WHERE u.userid = p.userid and p.pMain=1 and p.pThum!='nophoto.gif' and u.zipcode=c.zip and u.activation_flag='1' AND u.pro_visibility_flag='1' "; } else { $query12="SELECT u.*,pThum as photo_path,c.latitude,c.longitude FROM user u LEFT JOIN userphoto p ON u.userid = p.userid and p.pMain=1 LEFT JOIN mwm_mas_city c on u.zipcode=c.zip WHERE u.activation_flag='1' AND u.pro_visibility_flag='1' "; } /*if($acts=="fav") { //$query12="SELECT u.* FROM user u LEFT JOIN favorite_members f ON(u.userid=f.fav_userid) WHERE f.userid=$sessid AND u.pro_visibility_flag='1' "; if(($_POST['showphoto'] != '' && isset($_POST['showphoto'])) || (isset($_GET['showphoto']) && $_GET['showphoto']==1)) { $query12="SELECT u.*,p.pThum as photo_path FROM favorite_members f,user u,userphoto p WHERE u.userid=f.fav_userid and f.userid=$sessid and u.userid = p.userid and p.pThum!='nophoto.gif' and u.activation_flag='1' AND u.pro_visibility_flag='1' and p.pMain=1"; } else { $query12="SELECT u.* FROM user u LEFT JOIN favorite_members f ON(u.userid=f.fav_userid) WHERE f.userid=$sessid AND u.pro_visibility_flag='1' "; } } if($acts == "latest") { $query12="SELECT u.*,pThum as photo_path, c.latitude, c.longitude FROM user u LEFT JOIN userphoto p ON u.userid = p.userid and p.pMain='1' LEFT JOIN mwm_mas_city c ON u.zipcode = c.zip WHERE u.activation_flag = '1' AND u.pro_visibility_flag = '1' "; } else */ // here search starts if($acts=="searched" && (isset($_REQUEST['searching']) || isset($_REQUEST['searching2']))) { if($txt_memname!="") { $query12.=" AND u.user_name LIKE '%$txt_memname%'"; } // for body type if(count($_POST['body_arr'])>0) { if($_POST['body_arr'][0]!="any") { for($i=0;$i<count($_POST['body_arr']);$i++) { if($qry_body == "") $qry_body .= " '".$_POST['body_arr'][$i]."' "; else $qry_body .= ", '".$_POST['body_arr'][$i]."' "; } } else if($_POST['body_arr'][0]=="any") { $sel_body="select body_type from master_fields where body_type != ''"; $rs_body=$db->select_data($sel_body); $qry_body = ""; for($i=0;$i<count($rs_body);$i++) { if($qry_body == "") $qry_body .= " '".$rs_body[$i][body_type]."' "; else $qry_body .= ", '".$rs_body[$i][body_type]."' "; } } if($qry_body!="") $query12.= " AND u.body in ($qry_body) "; } // for age query $query12.=" and (( TRUNCATE((TO_DAYS(now()) - TO_DAYS(date_of_birth))/365,0) >= $_POST[from_age] ) and (TRUNCATE((TO_DAYS(now()) - TO_DAYS(date_of_birth))/365,0) <= $_POST[to_age]) or (TRUNCATE((TO_DAYS(now()) - TO_DAYS(date_of_birth))/365,0) >=$_POST[from_age] and TRUNCATE((TO_DAYS(now()) - TO_DAYS(date_of_birth))/365,0) <= $_POST[to_age]))"; // attach active $active_arr = $_POST[active]; if($active_arr == 1) { $query12.=" and u.activation_flag ='1'"; } else if($active_arr == 2) { $query12.=" and SUBSTRING(u.login_time,11,2) between 0 and 12 " ; } else if($active_arr == 3) { $query12.=" and SUBSTRING(u.login_time,11,2) between 12 and 23 "; } // //attach height $sel_height="select id,height from master_fields"; $rs_height=$db->select_data($sel_height); for($h=$_POST[height_from]-1;$h<$_POST[height_to];$h++) { if($height_str=="") $height_str="'".$rs_height[$h][height]."'"; else $height_str.=",'".$rs_height[$h][height]."'"; } if($height_str!="") $query12.=" and u.height in ($height_str)"; // for eye if(count($_POST['eye_arr'])>0) { if($_POST['eye_arr'][0]!="any") { for($i=0;$i<count($_POST['eye_arr']);$i++) { if($qry_eye == "") $qry_eye .= " '".$_POST['eye_arr'][$i]."' "; else $qry_eye .= ", '".$_POST['eye_arr'][$i]."' "; } } else if($_POST['eye_arr'][0]=="any") { $sel_eye="select eye_color from master_fields where eye_color != ''"; $rs_eye=$db->select_data($sel_eye); $qry_eye = ""; for($i=0;$i<count($rs_eye);$i++) { if($qry_eye == "") $qry_eye .= " '".$rs_eye[$i][eye_color]."' "; else $qry_eye .= ", '".$rs_eye[$i][eye_color]."' "; } } if($qry_eye!="") $query12.= " AND u.eye in ($qry_eye) "; } Link to comment https://forums.phpfreaks.com/topic/47406-posting-comments/#findComment-282732 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.