Jump to content


Photo

Transfering variable to other pages


  • Please log in to reply
23 replies to this topic

#21 sasa

sasa
  • Staff Alumni
  • Advanced Member
  • 2,804 posts
  • LocationHrvatska

Posted 17 September 2006 - 08:09 PM

i don't see any error in this code
can we see all

#22 OLM3CA

OLM3CA
  • Members
  • PipPipPip
  • Advanced Member
  • 52 posts
  • LocationCyprus

Posted 17 September 2006 - 08:16 PM

search.php All codes

<?php

//mysql db connections

$kelime= $_GET['kelime'];

if(!isset($_GET['page'])){ 
    $page = 1; 
} else { 
    $page = $_GET['page']; 
} 

$max_results = 2; 


$from = (($page * $max_results) - $max_results); 

$query="SELECT * FROM linkler WHERE kelimeler LIKE '%".$kelime."%' LIMIT $from, $max_results";

$result=mysql_query($query);

?>
		<form method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>">
			<table border="0" cellspacing="0" cellpadding="0">
				<tr valign="middle">
					<td align="left"> SEARCH <br>
						<input name="kelime" type="text" class="input">&nbsp;</td>
					<td align="center" valign="bottom"><input type="submit" name="Submit"></td>
				</tr>
			</table>
		 </form>
<?php 



while($record=mysql_fetch_assoc($result)){

echo "<br>";
echo $record['name'];
echo "<br>";
echo $record['url'];
echo "<br>";
echo $record['kelimeler'];




$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM linkler"),0); 


$total_pages = ceil($total_results / $max_results); 



if($page > 1){ 
    $prev = ($page - 1); 
    echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$prev&keyword=$kelime\"></a>"; 
} 

for($i = 1; $i <= $total_pages; $i++){ 
    if(($page) == $i){ 
        echo "$i "; 
        } else { 
            echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$i&keyword=$kelime\">$i</a> "; 
    } 
} 


if($page < $total_pages){ 
    $next = ($page + 1); 
    echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$next&keyword=$kelime\"></a>";

} 

} 
?>

AMD rather than Intel , PHP rahter than ASP

#23 sasa

sasa
  • Staff Alumni
  • Advanced Member
  • 2,804 posts
  • LocationHrvatska

Posted 17 September 2006 - 08:50 PM

i make litle modification of your code try
<?php

//mysql db connections


$kelime= $_GET['kelime'];

if(!isset($_GET['page'])){ 
    $page = 1; 
} else { 
    $page = $_GET['page']; 
} 

$max_results = 2; 


$from = (($page * $max_results) - $max_results); 

$query="SELECT * FROM linkler WHERE kelimeler LIKE '%".$kelime."%' LIMIT $from, $max_results";

$result=mysql_query($query);

?>
		<form method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>">
			<table border="0" cellspacing="0" cellpadding="0">
				<tr valign="middle">
					<td align="left"> SEARCH <br>
						<input name="kelime" type="text" class="input">&nbsp;</td>
					<td align="center" valign="bottom"><input type="submit" name="Submit" value="Submit"></td>
				</tr>
			</table>
		 </form>
<?php 
if ($_GET['kelime']){ 


while($record=mysql_fetch_assoc($result)){

echo "<br>";
echo $record['name'];
echo "<br>";
echo $record['url'];
echo "<br>";
echo $record['kelimeler'];
echo '<hr />';
}



$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM linkler WHERE kelimeler LIKE '%".$kelime."%'"),0); 


$total_pages = ceil($total_results / $max_results); 



if($page > 1){ 
    $prev = ($page - 1); 
    echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$prev&kelime=$kelime\">prev </a>"; 
} 

for($i = 1; $i <= $total_pages; $i++){ 
    if(($page) == $i){ 
        echo "$i "; 
        } else { 
            echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$i&kelime=$kelime\">| $i</a> "; 
    } 
} 


if($page < $total_pages){ 
    $next = ($page + 1); 
    echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$next&kelime=$kelime\">| next</a>";

} 

} 
?>


#24 OLM3CA

OLM3CA
  • Members
  • PipPipPip
  • Advanced Member
  • 52 posts
  • LocationCyprus

Posted 17 September 2006 - 09:00 PM

How can I thank you ? Thank you very much? thank you thank  redarrow :)
and thank you all for your help :)
AMD rather than Intel , PHP rahter than ASP




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users