Solved

Changing System variables on button click

Posted on 2014-04-15
9
223 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
How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

 
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

830 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