Why doesn't this $_GET work - php

I am just trying to get the values from a table, but for some reason GET isn't working for me, or I am doing something wrong. Here is how I create my table in one php file:
<?php
.
.
.
.
echo "<tr>";
echo "<td>Login ID</td>";
$j=1;
echo "<td><input name=$j type='text' value='$line[$j]' size=20/></td>";
echo "</tr>";
echo "<tr>";
echo "<td>Name</td>";
$j=2;
echo "<td><input name=$j type='text' value='$line[$j]' size=20/></td>";
echo "</tr>";
echo "<tr>";
echo "<td>Password</td>";
$j=3;
echo "<td><input name=$j type='text' value='$line[$j]' size=20/></td>";
echo "</tr>";
echo "<tr>";
echo "<td>Birthday</td>";
$j=4;
echo "<td><input name=$j type='text' value='$line[$j]' size=20/></td>";
echo "</tr>";
echo "<tr>";
echo "<td>Address</td>";
$j=5;
echo "<td><input name=$j type='text' value='$line[$j]' size=20/></td>";
echo "</tr>";
echo "<tr>";
echo "<td>Email</td>";
$j=6;
echo "<td><input name=$j type='text' value='$line[$j]' size=20/></td>";
echo "</tr>";
echo "<tr>";
echo "<td>Phone Number</td>";
$j=7;
echo "<td><input name=$j type='text' value='$line[$j]' size=20/></td>";
echo "</tr>";
?>
The names should be the number 1-7 right?
In another php file I attempt to access the values in those fields with he following code:
<?php
.
.
.
.
$login_id = $_GET['1'];
$name = $_GET['2'];
$pw = $_GET['3'];
$bday = $_GET['4'];
$address = $_GET['5'];
$email = $_GET['6'];
$phno = $_GET['7'];
echo "new: $login_id, $name, $pw, $bday, $address, $email, $phno";
?>
Here is what I end up getting back: new: , , , , , ,
So what is it that I am doing wrong? I can't seem to find anything wrong with my code. I know I should probably be using $_POST for the password.

<?php
echo "<form action='otherfile.php' method='get'><tr>";
echo "<td>Login ID</td>";
$j=1;
echo "<td><input name=$j type='text' value='$j' size=20/></td>";
echo "</tr>";
echo "<tr>";
echo "<td>Name</td>";
$j=2;
echo "<td><input name=$j type='text' value='$j' size=20/></td>";
echo "</tr>";
echo "<tr>";
echo "<td>Password</td>";
$j=3;
echo "<td><input name=$j type='text' value='$j' size=20/></td>";
echo "</tr>";
echo "<tr>";
echo "<td>Birthday</td>";
$j=4;
echo "<td><input name=$j type='text' value='$j' size=20/></td>";
echo "</tr>";
echo "<tr>";
echo "<td>Address</td>";
$j=5;
echo "<td><input name=$j type='text' value='$j' size=20/></td>";
echo "</tr>";
echo "<tr>";
echo "<td>Email</td>";
$j=6;
echo "<td><input name=$j type='text' value='$j' size=20/></td>";
echo "</tr>";
echo "<tr>";
echo "<td>Phone Number</td>";
$j=7;
echo "<td><input name=$j type='text' value='$j' size=20/></td>";
echo "</tr>";
echo "<tr>";
echo "<td>Submit Data</td>";
echo "<td><input name='submitdata' type='submit' value='submit' size=20/></td>";
echo "</tr><form>";
?>
if you want submit then get the all value in otherfile.php file
try its working...

You have not put the <form> tag. Add tag in begining
<form action='another_page.php' method='get'>
and in the end write
<input type='submit' name='submit>
</form>
What it will do on submit it will forward the values to the another page.

<form name="login" method="get" action="youraction.php">
echo "<td><input name=$j type='text' value=$j /></td>";
</form>
youraction.php
---------------
<?php
if($_GET)
{
print_r($_GET);
}
?>

Related

PHP Basket quantity variable

I am trying to create a php page where the materials from database are populated. Users should be able to enter the quantity next to the item they wish to order and I have created a qty text field for this
<?php
session_start();
include("db.php");
$pagename="Order Material";
echo "<html>";
echo "<title>".$pagename."</title>";
echo "<h2>".$pagename."</h2>";
include ("detectlogin.php");
echo "<link rel=stylesheet type=text/css href=mystylesheet.css>";
$sql="select * from material";
$result=mysqli_query($con, $sql) or die(mysqli_error($con));
echo "<table border=1>";
echo "<tr>";
echo "<th>Material Name</th>";
echo "<th>Material Description</th>";
echo "<th>Toxicity Level</th>";
echo "</tr>";
while ($arraymaterials=mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>".$arraymaterials['materialName']."</td>";
echo "<td>".$arraymaterials['materialDescrip']."</td>";
echo "<td>".$arraymaterials['materialToxicity']."</td>";
echo "<td>Enter Quantity</td>";
echo "<td><input type=text name=qty value=qty size=5></td>";
echo "<form action=request_material.php method=post>";
echo "<input type=hidden name=materialcode value=".$arraymaterials['materialCode'].">";
echo "<td><input type=submit value='Request'></td>";
echo "</form>";
echo "</tr>";
}
echo "</table>";
?>
However, I cannot successfully post the value of qty on to the next page even though I have $qty=$_POST['qty']; on my request_material.php. Do you know why this value entered in the qty field cannot be posted onto the request_material.php page? Do I need a session variable?
thanks
Because input tag name="qty" is outside the form tag
echo "<td><input type=text name=qty value=qty size=5></td>";// outside form tag
echo "<form action=request_material.php method=post>";
echo "<input type=hidden name=materialcode value=" . $arraymaterials['materialCode'] . ">";
echo "<td><input type=submit value='Request'></td>";
echo "</form>";
You need to add it inside your form tag as
echo "<form action=request_material.php method=post>";
echo "<td><input type=text name=qty value=qty size=5></td>";// add inside it
echo "<input type=hidden name=materialcode value=".$arraymaterials['materialCode'].">";
echo "<td><input type=submit value='Request'></td>";
echo "</form>";
Please try this: I have updated the code:
echo "<table border=1>";
echo "<tr>";
echo "<th>Material Name</th>";
echo "<th>Material Description</th>";
echo "<th>Toxicity Level</th>";
echo "</tr>";
if(mysqli_num_rows($result)>0)
{
echo "<form action=request_material.php method=post>";
while ($arraymaterials=mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>".$arraymaterials['materialName']."</td>";
echo "<td>".$arraymaterials['materialDescrip']."</td>";
echo "<td>".$arraymaterials['materialToxicity']."</td>";
echo "<td>Enter Quantity</td>";
echo "<td><input type='text' name='qty[]' value='qty' size=5></td>";
echo "<input type=hidden name='materialcode[]' value=".$arraymaterials['materialCode'].">";
echo "<td><input type=submit value='Request'></td>";
echo "</tr>";
}
echo "</form>";
}
echo "</table>";
In request_material.php check value of $qty.It will be an array.for more details print_r($_POST) in request_material.php

Save button for each row in the table. PHP MYSQL

Please help, each row in the table has save button for editing/adding content. I have 3 textboxes in each row,PersoninCharge,PIC_Comments and Status. The user can add/edit these textboxes whenever they click the save button on that particular row. The problem is, whenever I add/edit data in one row, the save button can't read what particular row I edited.
The save button is perfectly running if I searched the invoice number first, but what I want is to directly edit/add the data in each row without searching it first.
Here's the code:
For the table:
<?php
if (mysqli_num_rows($result) > 0)
{
while($row = mysqli_fetch_array($result))
{
echo"<tr class=output2>";
echo "<td>$row[1]</td>";
echo "<td>$row[2]</td>";
echo "<td>$row[3]</td>";
echo "<td>$row[4]</td>";
echo "<td>$row[5]</td>";
echo "<td>$row[6]</td>";
echo "<td>$row[7]</td>";
echo "<td>$row[8]</td>";
echo "<td>$row[9]</td>";
echo "<td>$row[10]</td>";
echo "<td>$row[11]</td>";
echo "<td>$row[12]</td>";
echo "<td><input type='text' name='pic' value='$row[17]'></td>";
echo "<td><input type='text' name='comt' value='$row[18]'></td>";
echo "<td><input type='text' name='stat' value='$row[19]'></td>";
echo "<td><form name='update' method='POST'><input type='submit' name='save_btn' value='SAVE' style='font-size:1em;'/></form></td>";
echo "<td><input type='hidden' name='idtxt' value='$row[0]'/></td>";
echo "</tr>";
}
}
else
{
echo '<h3>No result found! </h3><br>';
}
$con->close();
For Save button:
if(isset($_POST['save_btn']))
{
$query2="UPDATE invalid_invoice SET UpdateBy='".$_SESSION['login_user']."', UpdateDateTime=NOW(), PersoninCharge='".$_POST['pic']."', PIC_Comments='".$_POST['comt']."', Status='".$_POST['stat']."' WHERE ID='".$_POST['idtxt']."'";
$con->query($query2);
$con->close();
echo '<h3 class="datasuccess">Data successfully added!</h3>';
}
I have edited your form. please have a look
<?php
if (mysqli_num_rows($result) > 0)
{
while($row = mysqli_fetch_array($result))
{
echo"<form name='update' method='POST'><tr class=output2>";
echo "<td>$row[1]</td>";
echo "<td>$row[2]</td>";
echo "<td>$row[3]</td>";
echo "<td>$row[4]</td>";
echo "<td>$row[5]</td>";
echo "<td>$row[6]</td>";
echo "<td>$row[7]</td>";
echo "<td>$row[8]</td>";
echo "<td>$row[9]</td>";
echo "<td>$row[10]</td>";
echo "<td>$row[11]</td>";
echo "<td>$row[12]</td>";
echo "<td><input type='text' name='pic' value='$row[17]'></td>";
echo "<td><input type='text' name='comt' value='$row[18]'></td>";
echo "<td><input type='text' name='stat' value='$row[19]'></td>";
echo "<td><input type='submit' name='save_btn' value='SAVE' style='font-size:1em;'/></td>";
echo "<td><input type='hidden' name='idtxt' value='$row[0]'/></td>";
echo "</tr></form>";
}
}
else
{
echo '<h3>No result found! </h3><br>';
}
$con->close();

Delete MySQL entry from HTML page

I'm trying to design a control page for my website that allows admins to delete requests to use a 3D printer at my school. The page displays a query of the schedule from the MySQL database and puts a delete button next to every entry. However, I would like to link the information in each entry to its respective delete button and have no idea how to do that. You can see the page itself here: http://kepler.covenant.edu/~techclub/PHP/manage%20printer%20schedule.php and this is my code for displaying the information
if ($result = $mysqli->query($query)) {
// see if any rows were returned
if ($result->num_rows > 0) {
// yes
// print them one after another
echo "<table cellpadding=10 border=1>";
echo "<tr>";
echo "<th>Control</th>";
echo "<th>Student ID</th>";
echo "<th>Last Name</th>";
echo "<th>First Name</th>";
echo "<th>Date and Time</th>";
echo "<th>Description</th>";
echo "</tr>";
$key = 1;
while($row = $result->fetch_array()) {
echo '<form method="POST" name="deleterequest" action = "delete request.php">';
echo "<tr>";
echo "<td><input name='".$row[5]."'type='submit' value='Delete' ></td>";
echo "<td>".$row[0]."</td>";
echo "<td>".$row[1]."</td>";
echo "<td>".$row[2]."</td>";
echo "<td>".$row[3]."</td>";
echo "<td>".$row[4]."</td>";
echo "</tr>";
echo "</form>";
}
echo "</table>";
}
else {
// no
// print status message
echo "No upcoming prints found!";
}
// free result set memory
$result->close();
}
I can't figure out how to link the information in a row with the delete button that I put in the row to send to the delete request.php program (which I have no code for yet)
you should put hidden field that hold each record id.
As below
while($row = $result->fetch_array()) {
echo "<tr>";
echo "<td>";
echo '<form method="POST" name="deleterequest" action = "delete request.php">';
echo "<input name='recored_id' type='hidden' value='".$row['id']."' >";
echo "<input name='delete'type='submit' value='Delete' >";
echo "</form>";
echo "</td>";
echo "<td>".$row[0]."</td>";
echo "<td>".$row[1]."</td>";
echo "<td>".$row[2]."</td>";
echo "<td>".$row[3]."</td>";
echo "<td>".$row[4]."</td>";
echo "</tr>";
echo "</form>";
}
Now from your request.php page you should do something like this
$recored_id = (int) $_POST['recored_id'];
$sql = "DELETE FROM table_name WHERE recored_id='$recored_id'";
Don't forget to give this code some security validation
all the best,
You're going to need some hidden inputs, like so:
while($row = $result->fetch_array()) {
echo "<tr>";
echo '<td><form method="POST" name="deleterequest" action = "deleterequest.php">';
echo "<input type='hidden' name='val0' value='" . $row[0] . "'>";
echo "<input type='hidden' name='val1' value='" . $row[1] . "'>";
echo "<input type='hidden' name='val2' value='" . $row[2] . "'>";
echo "<input type='hidden' name='val3' value='" . $row[3] . "'>";
echo "<input type='hidden' name='val4' value='" . $row[4] . "'>";
echo "<input name='".$row[5]."'type='submit' value='Delete' >";
echo "</form></td>";
echo "<td>".$row[0]."</td>";
echo "<td>".$row[1]."</td>";
echo "<td>".$row[2]."</td>";
echo "<td>".$row[3]."</td>";
echo "<td>".$row[4]."</td>";
echo "</tr>";
}
You should change the name of these inputs though

HTML form with multiple embedded tables, a lot of white space at top of page

I am having issues with a form I am trying to do in .php
I used tables, within the form, to format how I want the form to look like. The form is working correctly. But when I load the page, there is a huge white space at the top of the page, but I have no idea why it is there. I have tried looking at the source code in the web browser, and there are no html white space characters or anything out of the ordinary. Here is my code:
<?php
$strRequester = $_SERVER['PHP_SELF'];
echo "<div align=center>\n";
echo "<form name='SandwichOrder' action='$strRequester' method='POST'>\n";
####Bread####
echo "<table>\n";
echo "<tr><td bgcolor='CCCCCC'><input type='radio' name='size' value='whole'><b>Whole Sandwich</b></td>\n";
echo "<td bgcolor='CCCCCC'><input type='radio' name='size' value='half'><b>Half Sandwich</b></td></tr>\n";
echo "<tr><td> </td><td> </td></tr>\n";
echo "<tr><td bgcolor='CCCCCC'><b>Choose Your Roll/Bread:</b></td><td></td></tr><br>\n";
echo "<tr>\n";
echo "<td><input type='radio' name='bread' value='whiteroll'>White French Roll</td><br>\n";
echo "<td><input type='radio' name='bread' value='sourroll'>Sour Dough Roll</td><br>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td><input type='radio' name='bread' value='wheatroll'>Wheat French Roll</td><br>\n";
echo "<td><input type='radio' name='bread' value='dutchcrunch'>Dutch Crunch</td><br>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td><input type='radio' name='bread' value='nyrye'>New York Rye</td>\n";
echo "<td><input type='radio' name='bread' value='soursliced'>Sour Dough Bread</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td><input type='radio' name='bread' value='wheatsliced'>100% Whole Wheat Bread</td>\n";
echo "</tr>\n";
####Meat####
echo "<tr><td bgcolor='CCCCCC'><b>Choose Your Meat:</b></td><td></td></tr>\n";
echo "<tr>\n";
echo "<td><input type='radio' name='meat' value='roastbeef'>Roast Beef</td>\n";
echo "<td><input type='radio' name='meat' value='turkey'>Turkey</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td><input type='radio' name='meat' value='everroastchicken'>EverRoast Chicken</td>\n";
echo "<td><input type='radio' name='meat' value='ham'>Ham</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td><input type='radio' name='meat' value='salami'>Salami</td>\n";
echo "<td><input type='radio' name='meat' value='pastrami'>Pastrami</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td><input type='radio' name='meat' value='tune'>Tuna</td>\n";
echo "<td><input type='radio' name='meat' value='chickensalad'>Chicken Salad\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td><input type='radio' name='meat' value='veggiepatty'>Veggie Patty</td>\n";
echo "<td><input type='radio' name='meat' value='vegetarian'>Vegetarian</td>\n";
echo "</tr>\n";
####Cheese####
echo "<tr><td bgcolor='CCCCCC'><b>Choose Your Cheese:</b></td><td></td></tr>\n";
echo "<tr>\n";
echo "<td><input type='radio' name='cheese' value='cheddar'>Cheddar Cheese</td>\n";
echo "<td><input type='radio' name='cheese' value='swiss'>Swiss Cheese</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td><input type='radio' name='cheese' value='pepperjack'>Pepper Jack Cheese</td>\n";
echo "<td><input type='radio' name='cheese' value='american'>American Cheese</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td><input type='radio' name='cheese' value='provolone'>Provolone Cheese</td>\n";
echo "<td><input type='radio' name='cheese' value='none'>No Cheese</td>\n";
echo "</tr>\n";
####Condiments####
echo "<tr><td bgcolor='CCCCCC'><b>Choose Your Condiments:</b></td><td></td></tr>\n";
echo "<tr>\n";
echo "<td><input type='checkbox' name='mayonnaise' value='mayonnaise'>Add Mayonnaise</td>\n";
echo "<td><input type='checkbox' name='mustard' value='mustard'>Add Mustard</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td><input type='checkbox' name='lettuce' value='lettuce'>Add Lettuce</td>\n";
echo "<td><input type='checkbox' name='pickles' value='pickles'>Add Pickles</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td><input type='checkbox' name='tomato' value='tomato'>Add Tomato</td>\n";
echo "<td><input type='checkbox' name='peppers' value='peppers'>Add Peppers</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td><input type='checkbox' name='onion' value='onion'>Add Onion</td>\n";
echo "<td><input type='checkbox' name='olives' value='olives'>Add Olives</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td><input type='checkbox' name='salt' value='salt'>Add Salt</td>\n";
echo "<td><input type='checkbox' name='suboil' value='suboil'>Add Sub Oil</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td><input type='checkbox' name='pepper' value='pepper'>Add Pepper</td>\n";
echo "<td><input type='checkbox' name='avocado' value='avocado'>Add Avocado $0.50</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td><input type='checkbox' name='sprouts' value='sprouts'>Add Sprouts $0.50</td>\n";
echo "</tr>\n";
####Extras####
echo "<tr><td bgcolor='CCCCCC'><b>Choose Extra Meat or Cheese:</b></td><td></td></tr>\n";
echo "<tr>\n";
echo "<td><input type='checkbox' name='eroastbeef' value='eroastbeef'>Extra Roast Beef $1.00</td>\n";
echo "<td><input type='checkbox' name='eturkey' value='eturkey'>Extra Turkey $1.00</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td><input type='checkbox' name='eeverroastchicken' value='eeverroastchicken'>Extra EverRoast Chicken $1.00</td>\n";
echo "<td><input type='checkbox' name='eham' value='eham'>Extra Ham $1.00</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td><input type='checkbox' name='esalami' value='esalami'>Extra Salami $1.00</td>\n";
echo "<td><input type='checkbox' name='epastrami' value='epastrami'>Extra Pastrami $1.00</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td><input type='checkbox' name='etuna' value='etuna'>Extra Tuna $1.00</td>\n";
echo "<td><input type='checkbox' name='echickensalad' value='echickensalad'>Extra Chicken Salad $1.00</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td><input type='checkbox' name='ebacon' value='ebacon'>Extra Bacon $1.00</td>\n";
echo "<td><input type='checkbox' name='eveggiepatty' value='eveggiepatty'>Extra Veggie Patty $1.00</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td><input type='checkbox' name='evegetarian' value='evegetarian'>Extra Vegetarian $1.00</td>\n";
echo "<td><input type='checkbox' name='echeddar' value='echeddar'>Extra Cheddar $0.50</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td><input type='checkbox' name='eamerican' value='eamerican'>Extra American $0.50</td>\n";
echo "<td><input type='checkbox' name='eswiss' value='eswiss'>Extra Swiss Cheese $0.50</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td><input type='checkbox' name='eprovolone' value='eprovolone'>Extra Provolone Cheese $0.50</td>\n";
echo "<td><input type='checkbox' name='epepperjack' value='epepperjack'>Extra Pepper Jack Cheese $0.50</td>\n";
echo "</tr>\n";
echo "</table>\n";
####Name/Instructions####
echo "<b>Add your Name or Special Instructions</b><br>\n";
echo "<input type='text' name='instructions' value='' size='50'><br>\n";
echo "<input type='SUBMIT' name='SUBMIT' value='Add to Order'><br>\n";
echo "<input type='button' name='CANCEL' value='Cancel Item'>\n";
echo "</form>";
echo "</div>\n";
?>
I have also tried putting the entire form into a table, but that did not help either. Any suggestions would be great. I am fairly new to .php and html and so I do not even know where to start, in trouble shooting this issue.
Are you echoing the form into an html document? ie
<!doctype html>
<html>
<head>
<title>Title of the document</title>
</head>
<body>
YOUR FORM HERE
</body>
</html>
(http://www.w3schools.com/tags/tag_body.asp)
It's likely there is default styling on your div or on the html. In your css try:
html, body {
height: 100%;
width: 100%;
margin: 0;
}
div {
margin: 0;
}

PHP - How do you select a specific index of a row given by mysqli_fetch_array()?

Please refer to the image below:
http://i.stack.imgur.com/6hBPC.png
For instance, if a user clicks the button on the row which says "You have a quiz for math", the "Quiz ID" value of THAT row would then be passed to another PHP file.
Here's my current code:
<?php
$con=mysqli_connect("127.0.0.1", "root", "", "quizmaker");
if (mysqli_connect_errno($con))
{
echo "MySqli Error: " . mysqli_connect_error();
}
$now=date("m/d/Y");
$sql=mysqli_query($con,"SELECT * FROM quiz_query WHERE quiz_date='$now'");
$count=mysqli_num_rows($sql);
if($count>=1)
{
echo "<table border='1' width='50%'>";
echo "<form action='answer_quiz.php' method='post'>";
echo "<tr>
<td>You have a pending quiz!</td><td> </td><td> </td>
</tr>";
$number=1;
while($result=mysqli_fetch_array($sql))
{
echo "<tr>";
echo "<td>You have a quiz for " . $result['subject'] . "</td>";
echo "<td>Quiz ID: " .$result['quiz_ID']. "</td>";
echo "<td><input type='submit' name='button' id='button' value='Take Quiz'>";
echo "<input type='hidden' name='quiz[$number]' value='$result[quiz_ID]'>";
echo "</td>";
echo "</tr>";
$number++;
}
echo "</form>";
echo "</table>";
}
else
{
"You have no quiz! :D";
}
mysqli_close($con);
?>
Move this line:
echo "<form action='answer_quiz.php' method='post'>";
Inside of the while loop.
Also, change
echo "<input type='hidden' name='quiz[$number]' value='$result[quiz_ID]'>"
with
echo "<input type='hidden' name='quizId' value='$result[quiz_ID]'>"
Now, in answer_quiz.php you'll receive $_POST['quizId'] with the value you need.
Change your while to :
while( $row = $result->fetch_array(MYSQLI_ASSOC)){
echo $row['subject'];
}
You are forgetting quotes around your variable:
Instead of
echo "<input type='hidden' name='quiz[$number]' value='$result[quiz_ID]'>";
It should be
echo "<input type='hidden' name='quiz[$number]' value='$result[\"quiz_ID\"]'>";

Categories