[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 228
  • Last Modified:

Changing System variables on button click

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
breeze351
Asked:
breeze351
  • 3
  • 3
  • 2
  • +1
1 Solution
 
Dan CraciunIT ConsultantCommented:
What's a "system variable" in PHP?
0
 
breeze351Author Commented:
My bad $Session
0
 
Dan CraciunIT ConsultantCommented:
Can you please post your code?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
gr8gonzoConsultantCommented:
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
 
Ray PaseurCommented:
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
 
breeze351Author Commented:
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
 
Ray PaseurCommented:
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
 
breeze351Author Commented:
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
 
Ray PaseurCommented:
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now