Location: PHPKode > scripts > TrovaLavoro > trovalavoro/up.php
<?php
include("db/db.php");
if(isset($_POST["nome"]))
{
if(($_POST["nome"] == "") || ($_POST["tel"] == "") || ($_POST["text"] == ""))
{
echo 1;
}
else
{
$nome =  m($_POST["nome"]);
$tel = $_POST["tel"];
$text =  m($_POST["text"]);
$text = str_replace("\n","<br>",$text);
$idi = $_POST["idi"];
$e = mysql_query("INSERT INTO `res` (`nome`,`tel`,`text`,`idi`) VALUE('$nome','$tel','$text','$idi')");
if($e == true)
{
echo 2;
}
}
}
if(isset($_POST["nom"]))
{
if(($_POST["nom"] == "Settore") || ($_POST["telefono"] == "") || ($_POST["titolo"] == "") || ($_POST["select"] == "") || ($_POST["desc"] == ""))
{
echo 1;	
}
else
{
$nom = $_POST["nom"];
$tel = $_POST["telefono"];
$titolo =  m($_POST["titolo"]);
$select = $_POST["select"];
$desc = m($_POST["desc"]);
$desc = str_replace("\n","<br>",$desc);
$date = date("Y");
$date2 = date("d");
$m = date("m");
if($m == 1)
{
$m = "Gen";	
}
if($m == 2)
{
$m = "Feb";	
}
if($m == 3)
{
$m = "Mar";	
}
if($m == 4)
{
$m = "Apr";	
}
if($m == 5)
{
$m = "Mag";	
}
if($m == 6)
{
$m = "Giu";	
}
if($m == 7)
{
$m = "Lug";	
}
if($m == 8)
{
$m = "Ago";	
}
if($m == 9)
{
$m = "Sep";	
}
if($m == 10)
{
$m = "Ott";	
}
if($m == 11)
{
$m = "Nov";	
}
if($m == 12)
{
$m = "Dic";	
}
$date = $date2."-".$m."-".$date;
$e = mysql_query("INSERT INTO `offerta` (`nome`,`tel`,`titolo`,`regione`,`text`,`date`) VALUE('$nom','$tel','$titolo','$select','$desc','$date')");
if($e == true)
{
echo 2;
}
}
}
if(isset($_POST["sea"])){
$sea = $_POST["sea"];
$limit = 10; 
if(isset($_POST["re"]))
{
$re = $_POST["re"];
$query = "SELECT COUNT(*) as num FROM `offerta` WHERE `regione`='$re' AND `ap`='1' AND (`titolo` LIKE '%".$sea."%' OR `text` LIKE '%".$sea."%' OR `nome` LIKE '%".$sea."%')";	
}
else
{
$query = "SELECT COUNT(*) as num FROM `offerta` WHERE `ap`='1' AND (`titolo` LIKE '%".$sea."%' OR `text` LIKE '%".$sea."%' OR `nome` LIKE '%".$sea."%')";
}
$totp = mysql_fetch_array(mysql_query($query));
$totp = @$totp[num];
$stages = 3;
if(empty($_GET["last"]))
{
$_GET["last"] = 0;	
}
$page = mysql_real_escape_string($_GET["last"]);
if($page){
$start = ($page - 1) * $limit; 
}else{
$start = 0;	
}
if(isset($_POST["re"]))
{
$re = $_POST["re"];
$query1 = "SELECT * FROM `offerta` WHERE `regione`='$re' AND `ap`='1' AND (`titolo` LIKE '%".$sea."%' OR `text` LIKE '%".$sea."%' OR `nome` LIKE '%".$sea."%') ORDER BY id DESC LIMIT $start, $limit";	
}
else
{
$query1 = "SELECT * FROM `offerta` WHERE `ap`='1' AND (`titolo` LIKE '%".$sea."%' OR `text` LIKE '%".$sea."%' OR `nome` LIKE '%".$sea."%') ORDER BY id DESC LIMIT $start, $limit";
}
$ap = mysql_query($query1);
if ($page == 0){$page = 1;}
$prev = $page - 1;	
$next = $page + 1;							
$lastpage = ceil($totp/$limit);		
$LastPagem1 = $lastpage - 1;					
$page_nav = '';
if($lastpage > 1)
{	
$page_nav .= "";
if ($page > 1){
$page_nav.= "<a href='javascript:p($prev)'>&#171; Previous</a>";
}else{
$page_nav.= "<span id='current'>&#171; Previous</span>";	}
if ($lastpage < 7 + ($stages * 2))
{	
for ($counter = 1; $counter <= $lastpage; $counter++)
{
if ($counter == $page){
$page_nav.= "<span id='current'>$counter</span>";
}
else
{
$page_nav.= "<a href='javascript:p($counter)'>$counter</a>";}					
}
}
elseif($lastpage > 5 + ($stages * 2))
{
if($page < 1 + ($stages * 2))		
{
for ($counter = 1; $counter < 4 + ($stages * 2); $counter++)
{
if($counter == $page){
$page_nav.= "<span id='current'>$counter</span>";
}else{
$page_nav.= "<a href='javascript:p($counter)'>$counter</a>";}					
}
$page_nav.= "...";
$page_nav.= "<a href='javascript:p($LastPagem1)'>$LastPagem1</a>";
$page_nav.= "<a href='javascript:p($lastpage)'>$lastpage</a>";		
}
elseif($lastpage - ($stages * 2) > $page && $page > ($stages * 2))
{
$page_nav.= "<a href='javascript:p(1)'>1</a>";
$page_nav.= "<a href='javascript:p(2)'>2</a>";
$page_nav.= "...";
for ($counter = $page - $stages; $counter <= $page + $stages; $counter++)
{
if($counter == $page){
$page_nav.= "<span id='current'>$counter</span>";
}else{
$page_nav.= "<a href='javascript:p($counter)'>$counter</a>";}					
}
$page_nav.= "...";
$page_nav.= "<a href='javascript:p($LastPagem1)'>$LastPagem1</a>";
$page_nav.= "<a href='javascript:p($lastpage)'>$lastpage</a>";		
}
else
{
$page_nav.= "<a href='javascript:p(1)'>1</a>";
$page_nav.= "<a href='javascript:p(2)'>2</a>";
$page_nav.= "...";
for ($counter = $lastpage - (2 + ($stages * 2)); $counter <= $lastpage; $counter++)
{
if ($counter == $page){
$page_nav.= "<span id='current'>$counter</span>";
}else{
$page_nav.= "<a href='javascript:p($counter)'>$counter</a>";
}					
}
}
}
if ($page < $counter - 1){ 
$page_nav.= "<a href='javascript:p($next)'>Next &#187;</a>";
}else{
$page_nav.= "<span id='current'>Next &#187;</span>";
}
$page_nav.= "";			
}
$nav_d = mysql_num_rows($ap);
$d = 0;
?>

<?php
if($nav_d < 1)
{
?>
<p align="center">Nessun offerta trovata!</p>
<?php
}
while($d < $nav_d)
{
$id = mysql_result($ap,$d,"id");
$nome = mysql_result($ap,$d,"nome");
$titolo = mysql_result($ap,$d,"titolo");
$text = mysql_result($ap,$d,"text");
$regione = mysql_result($ap,$d,"regione");
$text = strip_tags($text);
$date = mysql_result($ap,$d,"date");
$fr = explode("-",$date);
if($d & 1)
{
?>
<div id="posts2">
<div id="posts_l">
<h3><a href="<?php echo $uu["url"]; ?>offerta/<?php echo $id; ?>/"><?php echo $titolo; ?></a></h3>
<p><?php echo cutsrr($text,60); ?> ...</p>
</div>
<div id="posts_l2"><h3><?php echo $nome; ?></h3>
<p>Italia, <?php echo $regione; ?></p></div>
<div id="posts_l3" align="right"><h3><?php echo $fr[0]." ".$fr[1]; ?></h3>
<p><?php echo $fr[2]; ?></p></div>
</div>
<?php 
}
else
{
?>
<div id="posts">
<div id="posts_l">
<h3><a href="<?php echo $uu["url"]; ?>offerta/<?php echo $id; ?>/"><?php echo $titolo; ?></a></h3>
<p><?php echo cutsrr($text,60); ?> ...</p>
</div>
<div id="posts_l2"><h3><?php echo $nome; ?></h3>
<p>Italia, <?php echo $regione; ?></p></div>
<div id="posts_l3" align="right"><h3><?php echo $fr[0]." ".$fr[1]; ?></h3>
<p><?php echo $fr[2]; ?></p></div>
</div>
<?php	
}
$d++;
}
?>
<div id="pagination" align="center"><?php echo $page_nav; ?></div>
<?php
}
?>
Return current item: TrovaLavoro