Solved

Changing System variables on button click

Posted on 2014-04-15
9
225 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 35

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 35

Expert Comment

by:Dan Craciun
ID: 40002332
Can you please post your code?
0
Containers & Docker to Create a Powerful Team

Containers are an incredibly powerful technology that can provide you and/or your engineering team with huge productivity gains. Using containers, you can deploy, back up, replicate, and move apps and their dependencies quickly and easily.

 
LVL 35

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 110

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 110

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 110

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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
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 viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

690 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