Strixy Posted July 29, 2006 Share Posted July 29, 2006 Let me start by explaining the project a little.Via a web form, the user selects 2 numbers (drop down) and 2 items (drop down). The numbers selected are to be placed in a table. The two items are selected from a drop down list of 6 choices. The location of those numbers (in the table) is determined by the users selection of item1 and item2. The correlation of item1 and item2 is stored in a mysql database and as described, determined by the users input.If I put a results table together, such that each cell in the table is a unique $variable, then I can store those variable names as searchable/selectable results in a mysql database. The end result is such that the users choice of items will determine the placement of the two numbers in a table of results.Example;[code]<?php// other stuff eg, web form, mysql_connect, select_db, etc... leading to $number1 = $_POST['number1']; $querya = mysql_select("SELECT varname FROM table WHERE $item1 = '$item2');// will reaturn a location variable ... $resulta = return($querya, 0); // ... "location1a" or "location2b" or whatever. "$".$resulta = $number1 // This is the part I'm having problems with.?>[/code]Lets say that the result of the query, for the sake of arguement, is "location2b".I would like to create a variable name that is determined by the mysql result and then set that variable to whatever $number1 was set to back at the $number1 = $_POST['number1'] so that I can echo the value of $number1 in the appropriate place. For example, a table 6x6 with 36 variables all connectted to the result of the mysql query. The result table looks like... (html removed)$location1a $location1b $location1c $location1d .... etc ....$location2a $location2b $location2c $location2d .... etc ....$location3a $location3b $location3c $location3d ....etc ....etc..etc..So, for example, if the mysql query returns "location2b" as the result of the query, I would like to be able to echo the value of $number1 in the proper location. Any thoughts would be appreciated. Even if its to say it can't be done so I can stop trying to figure this out. Thank you! Link to comment https://forums.phpfreaks.com/topic/15968-passing-variables-help-request/ Share on other sites More sharing options...
kenrbnsn Posted July 29, 2006 Share Posted July 29, 2006 You are trying to use variable variables (http://www.php.net/manual/en/language.variables.variable.php)[code]<?php// other stuff eg, web form, mysql_connect, select_db, etc... leading to $number1 = $_POST['number1']; $querya = "SELECT varname FROM table WHERE $item1 = '$item2'";// will reaturn a location variable ... $rw = mysql_query($querya) or die("Problem with the query: $querya<br>" . mysql_error()); $resulta = $rw['varname']; // ... "location1a" or "location2b" or whatever. $$resulta = $number1 // This is the part I'm having problems with.?>[/code]Ken Link to comment https://forums.phpfreaks.com/topic/15968-passing-variables-help-request/#findComment-65617 Share on other sites More sharing options...
Strixy Posted July 29, 2006 Author Share Posted July 29, 2006 Three things.Thank you for the quick answer.Thank you for providing a reference (URL).And thank you for providing some nice code.So, in summary.Thank you, thank you, thank you! Link to comment https://forums.phpfreaks.com/topic/15968-passing-variables-help-request/#findComment-65627 Share on other sites More sharing options...
Strixy Posted July 29, 2006 Author Share Posted July 29, 2006 And yes, it worked!Thanks again! Link to comment https://forums.phpfreaks.com/topic/15968-passing-variables-help-request/#findComment-65651 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.