I'm kind of new in this forum and I hope to become a static member
Anyway to my question:
I'm trying to seperate the results from the sql into pages with ID=x .
The problem is that i'm using a form to choose a category (of movies) and when I want to pass to the next page it asks me to choose again
cause the page reloaded .. so how do I solve it?
here is the code:
Code: Select all
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body dir="rtl">
<div id="wrapper">
<?php
require_once ("MyFormmScript.php");
require_once ("MyConnectionScript.php");
$selected=$_POST[movies];
if (isset($_GET["page"]))
$page = $_GET["page"];
else
$page=1;
$start_from = ($page-1) * 14;
mysql_select_db("MyDatabase", $con);
if ($selected=='הכל')
$result = mysql_query("SELECT * FROM MyTable ORDER BY year DESC LIMIT $start_from, 14");
else
$result = mysql_query("SELECT * FROM MyTable WHERE category='$selected' ORDER BY year DESC LIMIT $start_from, 5");
?>
<?php
if ($row = mysql_fetch_array($result)==0)
echo "<br /><center>אנא בחר קטגוריה</center>";
while($row = mysql_fetch_array($result))
{
?>
<hr/>
<div style="overflow : auto; height:140px;">
<!--תמונה וקישור הסרט !-->
<a href="<?php echo $row['mov_link'];?>" target="_new">
<img src="<?php echo $row['pic_link'];?>" alt="<?php echo $row['tags'];?>" width="160" height="120" align="right" /></a>
<div id="help"><font color="#000000">.</font></div>
<!--שם הסרט וקישור !-->
<div align="right" id="hesber4"><font size="3"><u><a href="<?php echo $row['mov_link']; ?>" alt="<?php echo $row['tags'];?>" target="_new" onMouseOver="javascript:this.style.color='#b02904'"
onMouseOut="javascript:this.style.color='#FFF'"><?php echo $row['name'];?></a></u></font><br /><br />
<!--תקציר !-->
<?php echo $row['summary'];?><br />
<!--טריילר !-->
<div align="left">לצפייה בטריילר <a href="<?php echo $row['trailer_link'];?>" target="_new">לחץ כאן</a>
</div>
</div>
<!--פרטים נוספים על הסרט !-->
<div id="hesber3" align="right">
<u>קטגוריה:</u> <?php echo $row['category'];?><br />
<u>שנת יציאה:</u> <?php echo $row['year'];?><br />
<u>אורך:</u> <?php echo $row['length'];?><br />
<u>שפה:</u> <?php echo $row['language'];?><br />
<u>מדינה:</u> <?php echo $row['country'];?><br />
<u>שחקנים:</u> <?php echo $row['actors'];?><br />
<u>תגיות:</u> <?php echo $row['tags'];?>
</div>
</div>
<?php
}
?>
<hr/>
</div>
<?php
if ($selected=='הכל')
$result = mysql_query("SELECT COUNT(name) FROM MyTable");
else
$result = mysql_query("SELECT COUNT(name) FROM MyTable WHERE category='$selected' ");
$row = mysql_fetch_array($result);
$total_records = $row[0];
$total_pages = ceil($total_records / 14);
echo "<center>";
for ($i=1; $i<=$total_pages; $i++)
{
echo "<a href='movies.php?page=".$i."'>".$i."</a> ";
}
echo "</center>";
?>
</body>
</html>
Code: Select all
if ($selected=='הכל')select * from xxx
else (means I choosed a category like comedy,action etc .. )
SELECT * FROM MyTable WHERE category ......
Here is a link to the page: http://www.sdarot2go.tv/movies.php
and choose the first option in the form "הכל" which means "all" cause you dont know hebrew.
Thanks in advanced.