lifeson2112 Posted February 26, 2007 Share Posted February 26, 2007 I need help finding out how to change a variable when a user clicks certain links. the change in variable also has to be displayed dynamically. is this possible? I'm extremely new to PHP, so any help would be greatly appreciated. Link to comment https://forums.phpfreaks.com/topic/40252-solved-can-i-dynamically-change-and-display-a-variable-when-a-user-clicks-a-button/ Share on other sites More sharing options...
fert Posted February 26, 2007 Share Posted February 26, 2007 look into sessions, $_GET and echo. That's all you need. Link to comment https://forums.phpfreaks.com/topic/40252-solved-can-i-dynamically-change-and-display-a-variable-when-a-user-clicks-a-button/#findComment-194736 Share on other sites More sharing options...
lifeson2112 Posted February 26, 2007 Author Share Posted February 26, 2007 Is there a way to do it without using forms? I guess the word I should have used was 'link'. Link to comment https://forums.phpfreaks.com/topic/40252-solved-can-i-dynamically-change-and-display-a-variable-when-a-user-clicks-a-button/#findComment-194740 Share on other sites More sharing options...
fert Posted February 26, 2007 Share Posted February 26, 2007 yes, with $_GET Link to comment https://forums.phpfreaks.com/topic/40252-solved-can-i-dynamically-change-and-display-a-variable-when-a-user-clicks-a-button/#findComment-194741 Share on other sites More sharing options...
lifeson2112 Posted February 26, 2007 Author Share Posted February 26, 2007 here's a sample of my retarded code so you can kinda get an idea of what I'm trying to do: <?php $siteValue = "not entered"; ?> <a href ="#" onClick="<?php $siteValue = "http://www.google.com"; ?>"> click here</a> <?php include( $siteValue); ?> Link to comment https://forums.phpfreaks.com/topic/40252-solved-can-i-dynamically-change-and-display-a-variable-when-a-user-clicks-a-button/#findComment-194743 Share on other sites More sharing options...
fert Posted February 26, 2007 Share Posted February 26, 2007 the only part of that code that wouldn't work would be this: <a href ="#" onClick="<?php $siteValue = "http://www.google.com"; ?>"> Link to comment https://forums.phpfreaks.com/topic/40252-solved-can-i-dynamically-change-and-display-a-variable-when-a-user-clicks-a-button/#findComment-194745 Share on other sites More sharing options...
lifeson2112 Posted February 26, 2007 Author Share Posted February 26, 2007 So, is there a way to use $_GET to get around this problem? Link to comment https://forums.phpfreaks.com/topic/40252-solved-can-i-dynamically-change-and-display-a-variable-when-a-user-clicks-a-button/#findComment-194746 Share on other sites More sharing options...
fert Posted February 26, 2007 Share Posted February 26, 2007 the best way to do what you want to do would be this page.htm <a href="page.php?page=http://google.com">Google</a> page.php include($_GET['page']); Link to comment https://forums.phpfreaks.com/topic/40252-solved-can-i-dynamically-change-and-display-a-variable-when-a-user-clicks-a-button/#findComment-194751 Share on other sites More sharing options...
lifeson2112 Posted February 26, 2007 Author Share Posted February 26, 2007 Sweet! works perfectly Link to comment https://forums.phpfreaks.com/topic/40252-solved-can-i-dynamically-change-and-display-a-variable-when-a-user-clicks-a-button/#findComment-194756 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.