Forum Moderators: coopster

Message Too Old, No Replies

reload page with changes

         

swati

3:18 pm on Nov 3, 2004 (gmt 0)

10+ Year Member



Hello,
I have a set of hyperlinks like :
Sept ¦ Oct ¦ Nov ¦ Dec
When the user clicks any of these months the page should be reloaded but with additional records displayed on that page depending on the query for chosen month.
How do I bring control back to the same page but with changes made to this page?
I m a newbie in PHP. help!
Thanks

DaButcher

7:26 pm on Nov 3, 2004 (gmt 0)

10+ Year Member



What will be stored for each month, and when? Just before the months have passed, or after too?

How do you want the new posts to be displayed? Display all new posts, untill the user has checked them as read? Or display all posts newer than x days?

I think those issues, and maybe more, are good for you to specify to us, before we can start using our caffeine filled brains.

swati

9:23 am on Nov 4, 2004 (gmt 0)

10+ Year Member



Main aim of the page is to display list of projects to which equipments have been assigned.(u dont have to pay much attention to this!)
No, nothing will be stored. Data has to be fetched from database. Example. if u select september then the same page should be reloaded but this time with the list of 'projects to which equipmentss are assigned for month of september'.
Sounds complicated but what i basically want to know is " how i can reload the page with extra records fetched from the database."

DaButcher

8:41 pm on Nov 4, 2004 (gmt 0)

10+ Year Member



it's not very hard..
you generate the query, based on what month is selected.

SELECT ... FROM ... WHERE month = '{$month}' ORDER BY id ... LIMIT 0, 5;

swati

1:55 pm on Nov 9, 2004 (gmt 0)

10+ Year Member



Another question:
I have a drop down menu named 'Site'. n below it a set of hyperlinks
sep¦oct¦nov¦dec¦

i have set the OnChange property of 'site' to this.form.submit()

My aim is to display certain records depending on the site chosen and the month.

However when i click on the site ....value for the month is empty and when i chose month the value for site is empty bcos on clicking either of them the page gets reloaded. Hence the records are not filtered by both the criterias

i need both the values at any given time. All of the above stuff is inside a form with post method

DaButcher

3:55 pm on Nov 9, 2004 (gmt 0)

10+ Year Member



Your last enquery is actually Client Side Scripting, not Server Side Scripting.

I guess there is a javascript part on this forum too, and I guess you can get more replies on this matter there.

Remember: Always make a backup-plan for those who do not have javascript or have it enabled.

swati

9:55 am on Nov 10, 2004 (gmt 0)

10+ Year Member



i have something called $site[0]
i want to access this in the form of $HTTP_GET_VARS[]
wats the syntax.......
for variables i know its $HTTP_GET_VARS['site'] but for array?

tried $HTTP_GET_VARS['site[0]'] & many things but doesnt work........

Salsa

10:26 am on Nov 10, 2004 (gmt 0)

10+ Year Member



Put this in your script and it will show you what's in $HTTP_GET_VARS.

?><pre><? echo "\$HTTP_GET_VARS ="; print_r($HTTP_GET_VARS);?></pre><?

swati

11:05 am on Nov 10, 2004 (gmt 0)

10+ Year Member



i tried it n the result is Array( )

what do i do to obtain the values inside the array

swati

11:44 am on Nov 10, 2004 (gmt 0)

10+ Year Member



i ll try to be clearer :
$site[0] gives me the value inside the array......
however print_r($HTTP_GET_VARS);
just gives me result : Array( )

why so?

i want the same result that i wud get on printing $site[0]

help!

Salsa

6:13 pm on Nov 10, 2004 (gmt 0)

10+ Year Member



To get values out of $HTTP_GET_VARS, you first need to put values into it. ;)

if print_r($HTTP_GET_VARS) only returns Array(), that means that the $HTTP_GET_VARS array is empty.

It looks like you are passing your variables in two ways, by links and by forms.

When you pass variables in a link, via a URL query string, they'll be in your $HTTP_GET_VARS array.

In that case, you need to have your links look something like

http://yoursite.com/page2.php?month=October&year=2004
. This will put the value "October" into the variable $month and the value "2004" into $year. Then you can retrieve them with $HTTP_GET_VARS['month'] and $HTTP_GET_VARS['year']. (Also with $_GET.)

When you pass variables via a form with method="post", the variables will be put in your $HTTP_POST_VARS array. eg; <select name="month"><option>October</option> ... </select>. Then retrieve with $HTTP_POST_VARS array['month']. (Also $_POST)

swati

11:36 am on Nov 17, 2004 (gmt 0)

10+ Year Member



hello,

i have links like Jan¦Feb¦Mar¦Apr¦May etc

i want that when i click on Mar. I want to display certain data for Feb, Mar and April.
I plan to put the values of 3 months in an array and loop thru the array to display appropriate values. But how do I obtain the names of 3 months? Also cud u please tell me the syntax of passing an array using method="get". I need a function which will determine the next month and the previous month depending on the month which has been clicked.
i searched but cud not find such a function.
Any help is appreciated.

Thank you

swati

2:45 pm on Nov 17, 2004 (gmt 0)

10+ Year Member



echo"<a href=\"".$_SERVER['PHP_SELF']."?page=$i&site=$site&monthYear=$HTTP_GET_VARS['monthYear']\">$i</a>";

gives me:
parse error, unexpected T_ENCAPSED_AND_WHITESPACE

where is the mistake

Thanks

Salsa

4:38 pm on Nov 17, 2004 (gmt 0)

10+ Year Member



Maybe concatenate $HTTP_GET_VARS['monthYear'] as you did $_SERVER['PHP_SELF'].".

echo"<a href=\"".$_SERVER['PHP_SELF']."?page=$i&site=$site&monthYear=".$HTTP_GET_VARS['monthYear']."\">$i</a>";

swati

5:32 pm on Nov 17, 2004 (gmt 0)

10+ Year Member



thank you it works!
Do you have any ideas as to how the other query of mine cud be solved?

Regards
Swati

Salsa

6:29 pm on Nov 17, 2004 (gmt 0)

10+ Year Member



I'm glad that worked for you.

In your other question, I wasnt' quite sure what we were working with. If you do something like having your months in an array...

$months = array('1' => 'Jan', '2' => 'Feb', '3' => 'Mar', ...);

and in your script you have

$current_month = 3; // (example for March) 
$current_year = 2004;
$prev months_year = $current_year;
$next months_year = $current_year;

if (isset($months[$current_month-1])) $prev_month = $months[$current_month-1]; 
else {
$prev_month = $months[12];
$prev months_year--;
}
if (isset($months[$current_month+1])) $next_month = $months[$current_month+1];
else {
$next_month = $months[1];
$next_months_year++;
}

This is fairly crude, but maybe that will help you.