0

Hi,I wrote a piece of code that admin can add publications with their date and users and admin can view all the publications in the same page sorted by time.till here it was ok,the problem started when i wanted to add a jump menu on top of the page so that when a user selects a year,only the publications of that year should be displayed,i dont want to add a button and i guess with onchange i should make this part that i cant because i dont know javascript.when the year is selected from client side,the page should refresh with the values of the server side related to that year.what should i do?i also send the part of code which is needed:

<form name="yearsel" method="GET" action="">

<?php
echo 'please choose the the publishing year:    ';
$startYr = date("Y");
echo "<select name='pubyr' onchange='publication.php' >\n";
for ($n=$startYr;$n>=$startYr-10;$n--)
{
echo  "<option value=$n";
echo "> $n\n";
}
echo '<option>before</option>';
echo "</select>\n";
echo '  <h2 class="style4"> </h2>';
echo '<img alt="" src="images/line.jpg" height="1" />';
 ?>
  </form> </p>

  <?php
require_once('config/database.php');
$pbyrstart = $_GET['pbyr']."/";
$pbyrstart .=01 ."/";
$pbyrstart .= 01;
$pbyend = $_GET['pbyr']."/";
$pbyrend .=12 ."/";
$pbyrend .= 30;

print ($pbyrstart);// it doesnt get the pbyr from the form therefore it prints like:/01/01 
//i wanted to make a timestamp and then compare the year 
$respublic= mysql_query("SELECT * FROM publication order by date desc where date>'$pbystart' and date < '$pbyrend' ");
$num=1;
while($rowpublic=mysql_fetch_assoc($respublic))
{
$timestamp=$rowpublic["date"];
$id=$rowpublic["uploadid"];//to make a link for any publication so that users can download it
$t=strtotime($timestamp);
$newdate=date('F Y',$t);//to display publication date like april 2010
echo ($num).','.($rowpublic["publisher"]).','.'<a href="/forums/download.php?id='.($id).'">'.($rowpublic["title"]).'</a>'.','.($rowpublic["description"]).','.($newdate); 
$num++;
echo '<p> </p>';
}
		?>

Edited by nav33n: Changed code snippet to forum thread. Use the snippet textbox to post your working and fully tested code snippet.

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by cwarn23
0

Not too clear as it looks like the text is copied directly from a homework book but if I'm correct what your looking for is ajax. This is where javascript can communicate with php without refreshing the page. There is a nice tutorial at http://www.tizag.com/ajaxTutorial/
Enjoy.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.