Jump to content
Sign in to follow this  
syira86

Coding search php mysql

Recommended Posts

yg image sy bg 2 sytm conference gak...juz cdgn sy jer nk wat mcm dlm image 2...bkn nmp menarik la..ape pndapt awk???

Share this post


Link to post
Share on other sites
org xguna dah kot system tu..org guna microsoft outloook sekarang ni untuk set date meeting or ape2 berkaitan dgn date...ke camne..??

Share this post


Link to post
Share on other sites
maaf la lme xonline...rabu nie sy dah kne present tp sy ade mslh dlm publish web kt web hosting..web hosting sy dah dpt..
Code:

Your Personal Account Information:
Account username: seminar.orgfree.com 
PassWord: cintaku
Host path: /home/vhosts/seminar.orgfree.com
Your Personal FTP Information:
FTP Server/Host: seminar.orgfree.com
FTP Login/Username: seminar.orgfree.com
FTP PassWord: cintaku
The basic ftp connection For Internet Explorer will be: ftp://seminar.orgfree.com:[email protected]/. Under Firefox/Opera you must install an additional plugin in order to transfer your files. For faster access, you can use an advanced ftp program like Smartftp or Filezilla. You can use as well our "File manager" utility - ftp client and advanced file editor incorporated.
 
Your Personal MySQL Information:
MySQL DataBase 216673
MySQL HostName localhost
MySQL UserName 216673
MySQL PassWord: Equal with account password
Enable your MySQL DataBase via Account Manager ---> use 'Create DB' button.

--------------------------------------------------------------------------------
 
To update/modify your account  go to Account Manager: http://www.orgfree.com/cgi-bin/amanager.cgi and use:

Account username: seminar.orgfree.com

Password: cintaku

Your phpMyAdmin is located at http://seminar.orgfree.com/pma/. Log in using MySQL username NOT account username.
 


sy xfhm nape ade error apebila sy tranfer file gune ftp kt web hosting...mcm xle run lgsung..dtbase sy install dlm web hosting tp ade error jg...leh ssape bg solution for my problem.

Share this post


Link to post
Share on other sites
die kuar error nie utk login admin
Code:

0) { $row=mysql_num_rows($stuff); echo header("Location: proses.php?"); exit; } else { echo("Login Incorrect. Please Try Again!"); } ?>

Share this post


Link to post
Share on other sites
Ini adalah open source dari aku untuk "Search User".. AKu newbie PHP nih.. kalau coding aku berterabur sory lah... just nak share..


Code ni berfungsi untuk mencari friend yang daftar dalam website aku...
by:
username,
fullname,
age,
gender,
location,

boleh dipilih untuk tepat dengan kritiria yang hendak dicari atau yang wujud pada mana2 kritirai yang hendak dicari

==========================CODE====================

<?php
if (!isset($_POST['fullname']) && !isset($_GET['fullname'])) { $fullname = ""; }
if (isset($_POST['fullname'])) { $fullname = $_POST['fullname']; }
if (isset($_GET['fullname'])) { $fullname = $_GET['fullname']; }
if (!isset($_POST['username']) && !isset($_GET['username'])) { $username = ""; }
if (isset($_POST['username'])) { $username = $_POST['username']; }
if (isset($_GET['username'])) { $username = $_GET['username']; }
if (!isset($_POST['age']) && !isset($_GET['age'])) { $age = ""; }
if (isset($_POST['age'])) { $age = $_POST['age']; }
if (isset($_GET['age'])) { $age = $_GET['age']; }
if (!isset($_POST['gender']) && !isset($_GET['gender'])) { $gender = "none"; }
if (isset($_POST['gender'])) { $gender = $_POST['gender']; }
if (isset($_GET['gender'])) { $gender = $_GET['gender']; }
if (!isset($_POST['location']) && !isset($_GET['location'])) { $location = ""; }
if (isset($_POST['location'])) { $location = $_POST['location']; }
if (isset($_GET['location'])) { $location = $_GET['location']; }
if (!isset($_POST['searchtype']) && !isset($_GET['searchtype'])) { $searchtype = "all"; }
if (isset($_POST['searchtype'])) { $searchtype = $_POST['searchtype']; }
if (isset($_GET['searchtype'])) { $searchtype = $_GET['searchtype']; }
?>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
.style5 {font-size: 12px; font-family: Arial, Helvetica, sans-serif; }
.style6 {
font-size: small;
font-family: Arial, Helvetica, sans-serif;
}
.style7 {
font-size: x-small;
font-family: Arial, Helvetica, sans-serif;
color: #008080;
}
-->
</style>
</head>

<body>
<table width="801" height="198" border="1" align="center" bordercolor="#0000FF">
<tr>
<td bordercolor="#0099FF" bgcolor="#00FFFF"><form name="form1" method="post" action="friendfinder.php">
<table align="center" bordercolor="#000000" style="width: 499px">
<tr>
<td colspan="3" style="height: 42px" class="style6">&nbsp;</td>
<td style="height: 42px"></td>
</tr>
<tr>
<td style="width: 67px"><span class="style5">Fullname</span></td>
<td>:</td>
<td>
<input name="fullname" <?php echo "value=\"" . $fullname . "\""; ?> type="text" id="fullname" size="50" style="font-size: 12px; font-family: Arial, Helvetica, sans-serif;"></td>
<td>&nbsp;</td>
</tr>
<tr>
<td style="width: 67px"><span class="style5">Username</span></td>
<td>:</td>
<td>
<input name="username" <?php echo "value=\"" . $username . "\""; ?> type="text" id="username" size="30" style="font-family: Arial, Helvetica, sans-serif; font-size: 12px"></td>
<td>&nbsp;</td>
</tr>
<tr>
<td style="width: 67px"><span class="style5">Age</span></td>
<td>:</td>
<td>
<input name="age" <?php echo "value=\"" . $age . "\""; ?> type="text" id="age" size="5" maxlength="2" style="font-family: Arial, Helvetica, sans-serif; font-size: 12px; width: 19px;"></td>
<td>&nbsp;</td>
</tr>
<tr>
<td style="width: 67px"><span class="style5">Gender</span></td>
<td>:</td>
<td>
<select name="gender" size="1" style="font-family: Arial, Helvetica, sans-serif; font-size: 12px">
<option value="none" <?php if ($gender == 'none' ) { echo "selected=\"\""; } ?> >Not Specific</option>
<option value="male" <?php if ($gender == 'male' ) { echo "selected=\"\""; } ?>>Male</option>
<option value="female" <?php if ($gender == 'female' ) { echo "selected=\"\""; } ?> >Female</option>
</select></td>
<td>&nbsp;</td>
</tr>
<tr>
<td style="width: 67px"><span class="style5">Location</span></td>
<td>:</td>
<td>
<input name="location" <?php echo "value=\"" . $location . "\""; ?> type="text" id="location" size="50" style="font-family: Arial, Helvetica, sans-serif; font-size: 12px"></td>
<td>&nbsp;</td>
</tr>
<tr>
<td style="width: 67px" rowspan="2"></td>
<td rowspan="2"></td>
<td style="height: 18px">
<input name="searchtype" type="radio" <?php if($searchtype == "all" ) { echo "checked=\"checked\""; } ?> value="all"><span class="style6">User
that have all above details</span></td>
<td rowspan="2"></td>
</tr>
<tr>
<td style="height: 3px">
<input name="searchtype" type="radio" <?php if($searchtype == "any" ) { echo "checked=\"checked\""; } ?> value="any"><span class="style6">User
that have any above details</span></td>
</tr>
<tr>
<td class="style7" style="width: 67px">&nbsp;</td>
<td class="style7">&nbsp;</td>
<td class="style7">
<input type="submit" name="Submit" value="Search" style="font-family: Arial, Helvetica, sans-serif; font-size: 12px; width: 74px;"></td>
<td>&nbsp;</td>
</tr>
<tr>
<td colspan="3" class="style7"><strong>Friend finder brought to you
by Cixent</strong></td>
<td>&nbsp;</td>
</tr>
</table>
</form></td>
</tr>
</table>




<p>&nbsp;</p>
</body>
</html>



<?php

//for search type
if(isset($_POST['searchtype'])) {
if ($_POST['searchtype'] == 'all' ){
$searchtype = 'all';
}
if ($_POST['searchtype'] == 'any' ){
$searchtype = 'any';
}
}

if(isset($_GET['searchtype'])) {
if ($_GET['searchtype'] == 'all' ){
$searchtype = 'all';
}
if ($_GET['searchtype'] == 'any' ){
$searchtype = 'any';
}
}


//function explode
function explode_text($currentstring,$type,$searchtype) {
$array_word = explode(" ", $currentstring);
foreach($array_word as $numstr => $valuestr) {
if (isset($newword)) {
if ( $searchtype == 'all' ) {
$newword = $newword . " AND " . $type . " LIKE " . "'%" . $valuestr . "%'";
}
if ( $searchtype == 'any' ) {
$newword = $newword . " OR " . $type . " LIKE " . "'%" . $valuestr . "%'";
}
}
if (!isset($newword)) {
$newword = $type . " LIKE " . "'%" . $valuestr . "%'";
}
}
return $newword;
}

//function aging
function get_age($age) {
$newage = date('Y') - $age;
return $newage;
}


//for fullname post
if(isset($_POST['fullname'])) {
if ($_POST['fullname'] != null ) {
$cfullname = 1;
$fullname = $_POST['fullname'];
$fullnamestr = explode_text($fullname,'fullname',$searchtype);
}
if ($_POST['fullname'] == null ) {
$cfullname = 0;
}
}

//for fullname get
if(isset($_GET['fullname'])) {
if ($_GET['fullname'] != null ) {
$cfullname = 1;
$fullname = $_GET['fullname'];
$fullnamestr = explode_text($fullname,'fullname',$searchtype);
}
if ($_GET['fullname'] == null ) {
$fullname = $_GET['fullname'];
$cfullname = 0;
}
}


//for location post
if(isset($_POST['location'])) {
if ($_POST['location'] != null ) {
$clocation = 1;
$location = $_POST['location'];
$locationstr = explode_text($location,'location',$searchtype);
}
if ($_POST['location'] == null ) {
$location = $_POST['location'];
$clocation = 0;
}
}

//for location get
if(isset($_GET['location'])) {
if ($_GET['location'] != null ) {
$clocation = 1;
$location = $_GET['location'];
$locationstr = explode_text($location,'location',$searchtype);
}
if ($_GET['location'] == null ) {
$location = $_GET['location'];
$clocation = 0;
}
}

//for username post
if(isset($_POST['username'])) {
if($_POST['username'] != null ) {
$cusername = 1;
$username = $_POST['username'];
$usernamestr = "username like '%" . $username . "%'";
}
if($_POST['username'] == null ) {
$username = $_POST['username'];
$cusername = 0;
}
}

//for username get
if(isset($_GET['username'])) {
if($_GET['username'] != null ) {
$cusername = 1;
$username = $_GET['username'];
$usernamestr = "username like '%" . $username . "%'";
}
if($_GET['username'] == null ) {
$username = $_GET['username'];
$cusername = 0;
}
}



=============================SAMBUNG PADA POST SETERUSNYA====================

Share this post


Link to post
Share on other sites
====================SAMBUNG CODING==============

//for age post
if(isset($_POST['age'])) {
if($_POST['age'] != null ) {
$cage = 1;
$age = $_POST['age'];
$agestr = "yyyy = '" . get_age($age) . "'";
}
if($_POST['age'] == null ) {
$age = $_POST['age'];
$cage = 0;
}
}

//for age get
if(isset($_GET['age'])) {
if($_GET['age'] != null ) {
$cage = 1;
$age = $_GET['age'];
$agestr = "yyyy = '" . get_age($age) . "'";
}
if($_GET['age'] == null ) {
$age = $_GET['age'];
$cage = 0;
}
}

//for gender post
if(isset($_POST['gender'])) {
if($_POST['gender'] != 'none' ) {
$cgender = 1;
$gender = $_POST['gender'];
$genderstr = "gender = '" . $gender . "'";
}
if($_POST['gender'] == 'none' ) {
$gender = $_POST['gender'];
$cgender = 0;
}
}

//for gender get
if(isset($_GET['gender'])) {
if($_GET['gender'] != 'none' ) {
$cgender = 1;
$gender = $_GET['gender'];
$genderstr = "gender = '" . $gender . "'";
}
if($_GET['gender'] == 'none' ) {
$gender = $_GET['gender'];
$cgender = 0;
}
}




if (!isset($_GET['searchtype']) && !isset($_POST['searchtype'])) {
die();
}
//get mysql statement for all detail
$mainquery = "SELECT * FROM users where ";
if ($cfullname == 1) {
$mainquery = $mainquery . " " . $fullnamestr;
}

if ($cfullname == 1) {
if ($clocation == 1) {
if ($searchtype == 'all') {
$mainquery = $mainquery . " and " . $locationstr;
}
if ($searchtype == 'any') {
$mainquery = $mainquery . " or " . $locationstr;
}

}
}
if ($cfullname == 0) {
if ($clocation == 1) {
$mainquery = $mainquery . " " . $locationstr;
}
}

if ($cfullname == 1 || $clocation == 1 ) {
if ($cusername == 1 ) {
if ($searchtype == 'all') {
$mainquery = $mainquery . " and " . $usernamestr;
}
if ($searchtype == 'any') {
$mainquery = $mainquery . " or " . $usernamestr;
}
}
}
if ($cfullname == 0 && $clocation == 0 ) {
if ($cusername == 1 ) {
$mainquery = $mainquery . " " . $usernamestr;
}
}

if ($cfullname == 1 || $clocation == 1 || $cusername == 1 ) {
if ($cage == 1) {
if ($searchtype == 'all') {
$mainquery = $mainquery . " and " . "$agestr";
}
if ($searchtype == 'any') {
$mainquery = $mainquery . " or " . "$agestr";
}
}
}
if ($cfullname == 0 && $clocation == 0 && $cusername == 0 ) {
if ($cage == 1) {
$mainquery = $mainquery . " " . $agestr;
}
}

if ($cfullname == 1 || $clocation == 1 || $cusername == 1 || $cage == 1 ) {
if ( $cgender == 1 ) {
if ($searchtype == 'all') {
$mainquery = $mainquery . " and " . $genderstr;
}
if ($searchtype == 'any') {
$mainquery = $mainquery . " or " . $genderstr;
}
}
}
if ($cfullname == 0 && $clocation == 0 && $cusername == 0 && $cage == 0 ) {
if ( $cgender == 1 ) {
$mainquery = $mainquery . " " . $genderstr;
}
}

//check if this round was not page 1
if(isset($_GET['page'])) {
$page = $_GET['page'];
}
if(!isset($_GET['page'])) {
$page = 1;
}

if ($cfullname == 1 || $clocation == 1 || $cusername == 1 || $cage == 1 || $cgender == 1 ) {
$querytotal = $mainquery;
if ($page == 1) {
$mainquery = $mainquery . " limit 0, 10";
}
if ($page != 1) {
$mainquery = $mainquery . " limit " . ($page - 1)*10 . ", 10";
}
}


if ($cfullname == 0 && $clocation == 0 && $cusername == 0 && $cage == 0 && $cgender == 0 ) {
echo "<center>Please enter any detail that you want to searching for</center>";
die();
}


//query database
include("connection.php");
$queryusers = $mainquery;
$queryresult = mysql_query($queryusers) or die(mysql_error());
$resultquerytotal = mysql_query($querytotal) or die(mysql_error());
$totalresult = mysql_num_rows($resultquerytotal);
$totalshow = mysql_num_rows($queryresult);
echo "<center><a>Show " . $totalshow . " of " . $totalresult . " results</a></center>";

while($forshow = mysql_fetch_assoc($queryresult)){
$susername = $forshow['username'];
$sfullname = $forshow['fullname'];
$sage = $forshow['yyyy'];
$sage = date('Y') - $sage;
$sgender = $forshow['gender'];
$slocation = $forshow['location'];
$usertable = $susername . "_mytable";
$querydetail = "SELECT * FROM " . $usertable;

//query user details
$usertable = $susername . "_mytable";
$querydetail = "SELECT * FROM " . $usertable;
$querydetailresult = mysql_query($querydetail) or die(mysql_error());

$scareer = mysql_result($querydetailresult, 0, 'col14');
$sgroup = mysql_result($querydetailresult, 0, 'col4');
$sinterest = mysql_result($querydetailresult, 0, 'col16');
$sfavourite = mysql_result($querydetailresult, 0, 'col18');
$saboutme = mysql_result($querydetailresult, 0, 'col31');
if ($scareer == null ) { $scareer = "Unknown"; }
if ($sgroup == null ) { $sgroup = "Unknown"; }
if ($sinterest == null ) { $sinterest = "Unknown"; }
if ($sfavourite == null ) { $sfavourite = "Unknown"; }
if ($saboutme == null ) { $saboutme = "Unknown"; }

echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"border-collapse: collapse\" bordercolor=\"#111111\" width=\"46%\" id=\"AutoNumber1\" height=\"1\">
<tr>
<td width=\"21%\" height=\"3\" rowspan=\"9\" align=\"left\" valign=\"top\">
<p align=\"center\"><font face=\"Arial\" size=\"2\">
<img border=\"0\" src=\"pic/18-08-07_1639.jpg\" width=\"138\" height=\"135\"></font></td>
<td width=\"2%\" height=\"1\"></td>
<td width=\"10%\" height=\"1\"><font face=\"Arial\" size=\"2\" color=\"#808080\">
Username</font></td>
<td width=\"2%\" height=\"1\" align=\"center\">
<p align=\"center\"><font face=\"Arial\" size=\"2\" color=\"#808080\">:</font></td>
<td width=\"65%\" height=\"1\"><font face=\"Arial\" size=\"2\" color=\"#808080\">" . $susername . "</font></td>
</tr>
<tr>
<td width=\"2%\" height=\"1\"></td>
<td width=\"10%\" height=\"1\"><font face=\"Arial\" size=\"2\" color=\"#808080\">
Fullname</font></td>
<td width=\"2%\" height=\"1\" align=\"center\">
<font face=\"Arial\" size=\"2\" color=\"#808080\">:</font></td>
<td width=\"65%\" height=\"1\"><font face=\"Arial\" size=\"2\" color=\"#808080\">" . $sfullname . "</font></td>
</tr>
<tr>
<td width=\"2%\" height=\"1\"></td>
<td width=\"10%\" height=\"1\"><font face=\"Arial\" size=\"2\" color=\"#808080\">
Gender</font></td>
<td width=\"2%\" height=\"1\" align=\"center\">
<font face=\"Arial\" size=\"2\" color=\"#808080\">:</font></td>
<td width=\"65%\" height=\"1\"><font face=\"Arial\" size=\"2\" color=\"#808080\">" . $sgender . "</font></td>
</tr>
<tr>
<td width=\"2%\" height=\"1\"></td>
<td width=\"10%\" height=\"1\"><font face=\"Arial\" size=\"2\" color=\"#808080\">Age</font></td>
<td width=\"2%\" height=\"1\" align=\"center\">
<font face=\"Arial\" size=\"2\" color=\"#808080\">:</font></td>
<td width=\"65%\" height=\"1\"><font face=\"Arial\" size=\"2\" color=\"#808080\">" . $sage . "</font></td>
</tr>
<tr>
<td width=\"2%\" height=\"1\"></td>
<td width=\"10%\" height=\"1\"><font face=\"Arial\" size=\"2\" color=\"#808080\">
Location</font></td>
<td width=\"2%\" height=\"1\" align=\"center\">
<font face=\"Arial\" size=\"2\" color=\"#808080\">:</font></td>
<td width=\"65%\" height=\"1\"><font face=\"Arial\" size=\"2\" color=\"#808080\">". $slocation . "</font></td>
</tr>
<tr>
<td width=\"2%\" height=\"1\"></td>
<td width=\"10%\" height=\"1\"><font face=\"Arial\" size=\"2\" color=\"#808080\">
Career</font></td>
<td width=\"2%\" height=\"1\" align=\"center\">
<font face=\"Arial\" size=\"2\" color=\"#808080\">:</font></td>
<td width=\"65%\" height=\"1\"><font face=\"Arial\" size=\"2\" color=\"#808080\">" . $scareer . "</font></td>
</tr>
<tr>
<td width=\"2%\" height=\"1\"></td>
<td width=\"10%\" height=\"1\"><font face=\"Arial\" size=\"2\" color=\"#808080\">Group</font></td>
<td width=\"2%\" height=\"1\" align=\"center\">
<font face=\"Arial\" size=\"2\" color=\"#808080\">:</font></td>
<td width=\"65%\" height=\"1\"><font face=\"Arial\" size=\"2\" color=\"#808080\">" . $sgroup . "</font></td>
</tr>
<tr>
<td width=\"2%\" height=\"1\"></td>
<td width=\"10%\" height=\"1\"><font face=\"Arial\" size=\"2\" color=\"#808080\">
Interest</font></td>
<td width=\"2%\" height=\"1\" align=\"center\">
<font face=\"Arial\" size=\"2\" color=\"#808080\">:</font></td>
<td width=\"65%\" height=\"1\"><font face=\"Arial\" size=\"2\" color=\"#808080\">" . $sinterest . "</font></td>
</tr>
<tr>
<td width=\"2%\" height=\"1\"></td>
<td width=\"10%\" height=\"1\"><font face=\"Arial\" size=\"2\" color=\"#808080\">
Favourite</font></td>
<td width=\"2%\" height=\"1\" align=\"center\">
<font face=\"Arial\" size=\"2\" color=\"#808080\">:</font></td>
<td width=\"65%\" height=\"1\"><font face=\"Arial\" size=\"2\" color=\"#808080\">" . $sfavourite . "</font></td>
</tr>
<tr>
<td width=\"100%\" height=\"1\" colspan=\"5\"><font face=\"Arial\" size=\"2\">About me<b>:</b> <font color=\"#808080\">" . $saboutme . "</font></font></td>
</tr>
<tr>
<td width=\"100%\" height=\"1\" colspan=\"5\">
<p align=\"center\"><font face=\"Arial\">
<a href=\"http://127.0.0.1/cc/index.php?action=addfriend&friend=" . $susername . "\" style=\"text-decoration: none\">
<font size=\"2\">Add as friend </font> </a><font size=\"2\">,
<a href=\"http://127.0.0.1/cc/index.php?action=profile&user=" . $susername . "\" style=\"text-decoration: none\">Visit </a>,
</font>
<a href=\"http://127.0.0.1/cc/index.php?action=mymsg&body=compose&to=" . $susername . "\" style=\"text-decoration: none\">
<font size=\"2\">Send message </font> </a></font></p>
</p></td>
</tr>
</table><p>&nbsp;</p>";



}
if ($totalresult >> 0 ) {
$totalpage = ceil($totalresult/10);
echo "<p>&nbsp;</p><p>&nbsp;</p><center>";
echo "<font color=\"#000000\">Page: </font>";
$pn = "1";
while($pn <= $totalpage) {
if ( $pn == $page ) {
echo "<b><font size=\"4\" color=\"#000000\">" . $pn . "</font></b>&nbsp;";
}
if ( $pn != $page ) {
echo "&nbsp;<a href=\"index.php?action=friendfinder&page=" . $pn . "&fullname=" . $fullname . "&username=" . $username . "&age=" . $age . "&gender=" . $gender . "&location=" . $location . "&searchtype=" . $searchtype . "\">" . $pn . "</a>&nbsp;";
}
++$pn;
}
echo "<p></p></center>";
}
if ($totalresult == 0) {
echo "<center><a>There is no such user that can compare with that details</a></center>";
}
?>

==========================END==========================

Share this post


Link to post
Share on other sites

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.   Paste as plain text instead

  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.

Loading...
Sign in to follow this  

×
×
  • Create New...