Solved

Changing System variables on button click

Posted on 2014-04-15
9
219 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
 
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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 108

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 108

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 108

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Windows Script Host (WSH) has been part of Windows since Windows NT4. Windows Script Host provides architecture for building dynamic scripts that consist of a core object model, scripting hosts, and scripting engines. The key components of Window…
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.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

744 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now