How to insert into database using an array
Posted: Sun Jul 27, 2014 7:19 am
Warm greetings to all,
I am new to programming, in initial learning stage.
I have 10 questions in my database, and i am displaying them to user on his page.
When they enters the answer to it, that needs to go to database. My problem is that i haven't used array for INSERT ever. I googled on this too but not truly understood whats was going on. Can someone please help me on this?
Thanks
Shail
I am new to programming, in initial learning stage.
I have 10 questions in my database, and i am displaying them to user on his page.
When they enters the answer to it, that needs to go to database. My problem is that i haven't used array for INSERT ever. I googled on this too but not truly understood whats was going on. Can someone please help me on this?
Code: Select all
<?php
include_once"db_conx.php";
$sql = "SELECT * FROM mymake ";
$query = mysqli_query($db_conx,$sql);
$numrows = mysqli_num_rows($query);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style>
form > select { width:280px;}
</style>
</head>
<body>
<form>
<?php
if ($numrows > 0){
while ($row = mysqli_fetch_array($query, MYSQLI_ASSOC)) {
?>
<input type="text" name="q<?php echo $row["id"];?>" placeholder="<?php echo $row["question"];?>" size="82" disabled >
<select name="response" required="required">
<option value=""></option>
<option value="<?php echo $row["option1"]; ?>"><?php echo $row["option1"]; ?></option>
<option value="<?php echo $row["option1"]; ?>"><?php echo $row["option1"]; ?></option>
<option value="<?php echo $row["option2"]; ?>"><?php echo $row["option2"]; ?></option>
<option value="<?php echo $row["option3"]; ?>"><?php echo $row["option3"]; ?></option>
</select>
<br>
<?php
}
}
?>
<br /><input type="submit" value="Ready to Go" name="submit" />
<input type="reset" value="Reset" name="reset" />
</form>
</body>
</html>Thanks
Shail