473,386 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

defining the variable

56
hello everyone,
This is my code:

if($i==1)
{
echo "first time";
$i++;
echo '<script language="javascript">document.location="'.basenam e($_SERVER['PHP_SELF']).'";</script>'; //it reloads my page
}
if($i==2)
{
echo "second time";
$i++;
echo '<script language="javascript">document.location="'.basenam e($_SERVER['PHP_SELF']).'";</script>';
}
if($i==3)
{
echo "third time";
$i++;
echo '<script language="javascript">document.location="'.basenam e($_SERVER['PHP_SELF']).'";</script>'; //it reloads my page
}


i want that how can i maintain the incremented value of variable $i after each page reload.so that i can execute specific code in if statement.

thanks in advance...
Jan 8 '08 #1
1 1304
Hello Sejal...

Yah i am the same Paresh...

When your page get's reload the value of variable initialize..
To maintain the value of variable, you have to store it in session and when your page get loaded retrieve it from session like below:

if (isset($_SESSION['i']))$i=$_SESSION['i'];
Then do your as usual coding...
don't forget to add add session_start() if it is not there... :)

Have a nice time..
Say thanks if it helps..

Paresh

hello everyone,
This is my code:

if($i==1)
{
echo "first time";
$i++;
echo '<script language="javascript">document.location="'.basenam e($_SERVER['PHP_SELF']).'";</script>'; //it reloads my page
}
if($i==2)
{
echo "second time";
$i++;
echo '<script language="javascript">document.location="'.basenam e($_SERVER['PHP_SELF']).'";</script>';
}
if($i==3)
{
echo "third time";
$i++;
echo '<script language="javascript">document.location="'.basenam e($_SERVER['PHP_SELF']).'";</script>'; //it reloads my page
}


i want that how can i maintain the incremented value of variable $i after each page reload.so that i can execute specific code in if statement.

thanks in advance...
Jan 8 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Sriram Chadalavada | last post by:
Hello everyone, I am a newbie to Python with experience in C programming. For my project, I am re-writing C routines as Python functions. I am currently using raw numerical values and was...
0
by: Dotnetified | last post by:
Reposting after about 2 weeks of no response ... thanks if you can help... ---------------------------------------------------------------------------- -------------- To anyone who thinks they...
2
by: Hamish Symington | last post by:
Hello, I'm trying to re-code a site which I wrote in PHP into ASP.NET using Visual Basic .NET. Something PHP has which has proved invaluable is the concept of variable variables. I haven't...
10
by: nambissan.nisha | last post by:
I am facing this problem.... I have to define a structure at runtime as the user specifies... The user will tell the number of fields,the actual fields...(maybe basic or array types or...
11
by: Rahul | last post by:
Hi, Is the following correct? Here i have declaread a char array in case 1: and am using the same in case 2: first I tried another definition of ch in case 2: assuming that if i=2 then char ch...
1
by: Gary Wessle | last post by:
Hi can I declare an ofstream in a class declaration in .h file and define it inside a method in the .cpp file? if so, what does the syntax of defining it looks like. I tried .... ofstream...
26
by: Cliff Williams | last post by:
Can someone explain the pros/cons of these different ways of creating a class? // 1 function myclass() { this.foo1 = function() {...} } // 2a
11
by: whirlwindkevin | last post by:
I saw a program source code in which a variable is defined in a header file and that header file is included in 2 different C files.When i compile and link the files no error is being thrown.How is...
1
by: mrsmith221189 | last post by:
Hello everyone. I'm a novice to XML/XSL so it would be great to learn from the experts. The ouput of my xml file is BBC EPG(Electronic Programme Guide) table. I'm having problems defining a...
2
by: ismailc | last post by:
Hi, I don't know xml. The stylesheet identifies all the objects from DB & as it reads through the DB, it checks the next object "for-each", I need to check the third object as well & define within...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.