Solved

Changing System variables on button click

Posted on 2014-04-15
9
221 Views
Last Modified: 2014-04-30
I have 4 buttons. "Up", "Down", "Left" and "Right".
The original page that this is coming from passes the data in a system variable.
Is there a way that when the button is clicked, I can change the system variable.
I've hard coded it now so that it works for "UP".
0
Comment
Question by:breeze351
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 34

Expert Comment

by:Dan Craciun
ID: 40002258
What's a "system variable" in PHP?
0
 

Author Comment

by:breeze351
ID: 40002304
My bad $Session
0
 
LVL 34

Expert Comment

by:Dan Craciun
ID: 40002332
Can you please post your code?
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 34

Expert Comment

by:gr8gonzo
ID: 40002340
Read my article on this topic:

http://www.experts-exchange.com/Programming/Languages/Scripting/PHP/A_11997-How-to-Make-Javascript-Talk-to-PHP.html

Basically, you can use Javascript with the "onclick" event of each button to send the new value to a PHP script and have the PHP script update the session variable.
0
 
LVL 109

Expert Comment

by:Ray Paseur
ID: 40002866
See if this jQuery / AJAX script gives you some ideas.  The information that is passed could be anything you typed in or it could be pre-coded like Up Right Down Left...
http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Jquery/A_10712-The-Hello-World-Exercise-with-jQuery-and-PHP.html
0
 

Author Comment

by:breeze351
ID: 40005113
I thought that I came up with an idea that doesn't you AJAX.  Let me know if this would work.

This is Manhattan so everything is a grid.  Up, down left right are all numbers.

The code that I have now works going north:

$north = $ROW['NOR'];
$south = $ROW['SOU'];
$east = $ROW['EAS'];
$west = $ROW['WES'];

$North_Button_North = $ROW['NOR'];
$North_Button_North = $north + "1";
$North_Button_South = $ROW['NOR'];
$North_Button_East = $ROW['EAS'];
$North_Button_West = $ROW['WES'];
$SqlString3 = "SELECT * FROM mapfile WHERE
                              NOR= \"$North_Button_North\"
                        and
                              SOU = \"$North_Button_South\"
                        and
                              EAS = \"$North_Button_East\"
                        and
                              WES = \"$North_Button_West\"                              
                              ";
$Survey_File = mysql_query($SqlString3);
$ROW2=mysql_fetch_array($Survey_File, MYSQL_BOTH);
$_SESSION['Data'] = $ROW2['SEQ'].$ROW2['STOREKEY'];
$_SESSION['Address'] = $ROW2['BNMB'];


Instead of saving it as a session variable, what if I created a variable that would pass the data to a php script as a $GET.  The php script could then update the session variable and reload the page.

I could do the same for South (down) East (left) and West (right) buttons.

I would have to create 4 different pages on the click, but it seems to me that it would work?
0
 
LVL 109

Expert Comment

by:Ray Paseur
ID: 40005163
I don't think we can get from this code to a working application without seeing the test data.  Can you please reduce this to the SSCCE and show us how to load the data base with your test data?  Thanks.

PS: You're going to need this article very soon, so I'll just leave it here for you.
0
 

Author Comment

by:breeze351
ID: 40007298
I know I'm going have to use AJAX.  I don't think I need it for this.
I'm going to try something and let you know.
Glenn
0
 
LVL 109

Accepted Solution

by:
Ray Paseur earned 500 total points
ID: 40007524
If you can show us the CREATE TABLE statements and the test data that we need to load in order to set up the SSCCE, I think we can help you save some time.
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
This article discusses four methods for overlaying images in a container on a web page
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question