Some reason when i call $_POST['xalue']
it will only return the first index of $xaxis
.
$xaxis = '["-100","-100","240","1056","3560","-650","5980.5","1020"]'
im just trying to pass the information so when the button is pressed to add the dashboard i can pass the data along. Thank you
$query = mysqli_query($db, "SELECT ID From users WHERE Username='$user'");
$fetch = mysqli_fetch_assoc($query);
$data = $fetch{"ID"};
$sql = "SELECT dashboardname FROM dashboards WHERE dashboarduserID=$data";
$result = $db->query($sql);
$addarray = array();
if ($result->num_rows > 0) {
global $xaxis;
echo $xaxis;
while ($row = $result->fetch_assoc()) {
array_push($addarray, $row['dashboardname']);
}
echo '<form method="post">';?>
<input type="text" name="xvalue" value="<?php echo $xaxis ?>">
<?php
echo 'Add current graph to :';
echo '<select name="addgraph">';
foreach ($addarray as $item) {
echo '<option value="' . $item . '">' . $item . '</option>';
}
echo '</select>';
echo '<input type="submit" name="addtodash" value="Add">';
echo '</form>';
} else {
echo "0 results";
if (isset($_REQUEST["addtodash"])) {
$xaxis = $_POST['xvalue'];
$query = mysqli_query($db, "SELECT ID From users WHERE Username='$user'");
$fetch = mysqli_fetch_assoc($query);
$data = $fetch{"ID"};
$nameofdash = $_POST['addgraph'];
mysqli_query($db, "INSERT INTO dashboardsdata (userid,dashboardname,xdata,ydata) VALUES ($data,\"$nameofdash\",\"$xaxis\",\"$yaxis\");");
echo "done";
}