Hello everyone.
This is my 1st post here, hope i will have many more.
I have a search script that searches a MySql database. In that database there are 30 objects, each of them with characterstics like height, weight, color,age,sex, etc. The search searches for these characteristics and displays me the matches. The problem is that it only displays one item/page. I do have the option to go next, back, but i would like it to display 5 or 10 a page. Now the problem is that im a total noob in php and this is a script that i have to do for work. The script was pre-coded by another employee who left on vacation and now i have to finish it but i have no ideea what im doing. I have about 5 days to finish this thing. It's done but my boss wants it to display 5 or 10 items/page.
I'm going to paste the code here. Hope you guys can help 🙂
<?
include ("sesiuni.php");
include ("config.php");
include ("functii_mail.php");
db_connect($dbserver,$dbuser,$dbpass,$dbname);
//variabile lang
global $matchfinder_title;
$users=array();
include ($lang);
if (is_banned($REMOTE_ADDR))
{
echo "IP banned!";
exit();
}
$comanda="?Submit=Submit";
if (isset($Submit))
{
$sql="select id from users where 1 ";
if (isset($sex_))
{
$sql.="and sex='$sex' ";
$comanda.="&sex=$sex&sex_=1";
}
else
{
$sex=" ";
}
if (isset($sexuality_))
{
$sql.="and sexuality='$sexuality' ";
$comanda.="&sexuality=$sexuality&sexuality_=1";
}
else
{
$sexuality=" ";
}
if (isset($location_))
{
$sql.="and location like '%$location%' ";
$comanda.="&location=$location&location_=1";
}
else
{
$location=" ";
}
if (isset($country_))
{
$sql.="and country='$country' ";
$comanda.="&country=$country&country_=1";
}
else
{
$country=" ";
}
if (isset($zodia_))
{
$sql.="and zodia='$zodia' ";
$comanda.="&zodia=$zodia&zodia_=1";
}
else
{
$zodia=" ";
}
if (isset($marital_status_))
{
$sql.="and marital_status='$marital_status' ";
$comanda.="&marital_status=$marital_status&marital_status_=1";
}
else
{
$marital_status=" ";
}
if (isset($eyes_colour_))
{
$sql.="and eyes_colour like '%$eyes_colour%' ";
$comanda.="&eyes_colour=$eyes_colour&eyes_colour_=1";
}
else
{
$eyes_colour=" ";
}
if (isset($hair_colour_))
{
$sql.="and hair_colour like '%$hair_colour%' ";
$comanda.="&hair_colour=$hair_colour&hair_colour_=1";
}
else
{
$hair_colour=" ";
}
if (isset($weight_))
{
$sql.="and weight$op_weight$weight ";
$comanda.="&weight=$weight&op_weight=$op_weight&weight_=1 ";
}
else
{
$weight=0;
}
if (isset($height_))
{
$sql.="and height$op_height".str_replace('ft','',$height)." ";
$comanda.="&height=$height&op_height=$op_height&height_=1 ";
}
else
{
$height=0;
}
if (isset($music_))
{
$sql.="and music like '%$music%' ";
$comanda.="&music=$music&music_=1";
}
else
{
$music=" ";
}
if (isset($age_search_))
{
$sql.="and age>$age_min and age<$age_max ";
$comanda.="&age_min=$age_min&age_max=$age_max&age_search_=1";
}
else
{
$age_min=0;
$age_max=0;
}
if (isset($salvare_))
{
$sql1="insert into match_finder values ($usernick,'$sex','$sexuality','$location','$country',
'$zodia','$marital_status','$eyes_colour','$hair_colour',$weight,'$op_weight',$height,'$op_height',
'$music',$age_min,$age_max)";
save_match_finder($sql1,$usernick);
}
if (!isset($pas))
{
$pas=0;
}
$res_logger = mysql_query ($sql);
if (!$res_logger)
{
echo mysql_error();
exit;
}
$total_match=mysql_numrows($res_logger);
$sql.=" limit $pas,1";
$res_logger = mysql_query ($sql);
if (!$res_logger) {
echo mysql_error();
exit;
}
$num=mysql_numrows($res_logger);
if ($num<>0) {
$i=0;
while ($i<$num) {
$id=mysql_result($res_logger,$i,"id");
$sunt_rezultate=true;
$users[]=$id;
$i++;
}
} else {
$sunt_rezultate=false;
}
}
?>