Hey,
When my page loads I use PHP to pull the names of the tables out of a specific database, I then retrieve the values and use echo to write javascript with variable names that are in the database.
Here is some code:
So, in my mind, I'm writing javascript something like this:
table1[0][0] = "value";
table1[0][1] = "next value"; etc.,
Now, I have a javascript function, and I want to retrieve some information from the table1 variable (which is in javascript).
The name of the tables are contained in a select box (drop down box) so I can easily retrieve the value of that select box, but I don't know how to use it as a variable.
Is this possible? Alternatively, I thought I could make a text box control and store the information in there, hide it, and then read it in javascript and then format it.
When my page loads I use PHP to pull the names of the tables out of a specific database, I then retrieve the values and use echo to write javascript with variable names that are in the database.
Here is some code:
PHP:
echo "<script type='text/javascript'>";
for ($i = 0; $i<count($tablesList); $i++) {
//echo $tablesList[$i]." ".$i." - ";
$sql = "SELECT * FROM ".$tablesList[$i]." ";
$result = mysql_query($sql, $con);
if ($result) {
echo "var ".$tablesList[$i]." = new Array(".count($tablesList[$i].");";
for ($k = 0; $k < count($tablesList[$i]); $k++) {
echo $tablesList[$i]."[".$k."] = new Array();";
}
}
while ($row = mysql_fetch_array($result)) {
echo $tablesList[$i]."[".$z."][0] = '".$row["adname"]."';";
echo $tablesList[$i]."[".$z."][1] = '".$row["url"]."';";
echo $tablesList[$i]."[".$z."][2] = '".$row["linkto"]."';"; //what if the order the countries are retrieved aren't the same as they are in the index.
$z += 1;
}
}
echo "</script>";
table1[0][0] = "value";
table1[0][1] = "next value"; etc.,
Now, I have a javascript function, and I want to retrieve some information from the table1 variable (which is in javascript).
The name of the tables are contained in a select box (drop down box) so I can easily retrieve the value of that select box, but I don't know how to use it as a variable.
PHP:
sometextbox.text = variables(text)[0][0]
Is this possible? Alternatively, I thought I could make a text box control and store the information in there, hide it, and then read it in javascript and then format it.