Jump to content

Posting Comments


oneday

Recommended Posts

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

  • 2 weeks later...

 

 

  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
Share on other sites

  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
Share on other sites

  • 1 month later...

<?

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
Share on other sites

// 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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.