a button for getting data from sql - php

i have create two table in my databases, 1.loginacc (stay login information(LoginID , Password and Permission)2.borrow (have book that the login borrowed,userid)
below is the code: and i have get all the user id,beside every user that i get from database loginacc ,it has a button called 'get information'.when i click it,it will have order of" select * from borrow where userid = (the loginid that shown out )
<?php
$con = mysql_connect("127.0.0.1","root","password");
mysql_select_db("babytradeapps");
$sql = "Select LoginID , Password , Permission
from loginacc where Permission = 1 ";
$results = mysql_query($sql,$con);
echo "<tr><th>Admin</th></tr>";
echo "<table border=5 cellpadding=10>";
echo "<tr><th></th><th>ac</th><th>pw</th><th>per</th><th></th></tr>";
while($row = mysql_fetch_array($results)) {
echo "<tr><td><form action='searchtable.php' method='get'><button type='button' name='button2' value='button2'>get information</button></td>
<td><input type=text id='row0' name='row0' value='$row[0]' /></td><td><input type=text id='row1' name='row1' value='$row[1]' /></td>
<td><input type=text id='row2' name='row2' value='$row[2]' /></td><td><input type='submit' name='button' value='change' /></td></tr>";
}
echo "</table>";

Why don't you use anchor (link) to send the loginID rather than using button , it will be simple . As far as i've understood your problem , you can do it as below .
echo "<table border=5 cellpadding=10>";
echo "<tr><th></th><th>ac</th><th>pw</th><th>per</th><th></th></tr>";
while($row = mysql_fetch_array($results)) {
echo "<tr><td>
<a href='searchtable.php?lid=$row[0]'>get information</a></td>
<td><input type=text id='row0' name='row0' value='$row[0]' /></td><td><input type=text id='row1' name='row1' value='$row[1]' /></td>
<td><input type=text id='row2' name='row2' value='$row[2]' /></td><td><input type='submit' name='button' value='change' /></td></tr>";
}
echo "</table>";
Now in the next page i.e. searchtable.php, just get that id using GET method and execute the query . This should be somehow like ,
<?php
$loginId = $_GET['lid'];
$con = mysql_connect("127.0.0.1","root","password");
mysql_select_db("babytradeapps");
$sql = "Select * from borrow where userid = $loginId";
$results = mysql_query($sql,$con);
$final_result = mysql_fetch_array($results);
print_r($final_result);
// Manipulate view with the result
?>

Related

Textareas causing problems to redirect to the next page

I have a database that is linked with the php. When I'm writing the first code, my web page gets redirected to the page 'mypage1.php'. But when I'm writing the second code, which is almost(exactly) the same, it doesn't get redirected to the mypage1.php. In the table inside my database, I have Orderid's that I'm using to relate to the php code. Could you tell me why doesn't the second code redirects to the same page? (It stays on the same page). The web page gets redirected to the mypage1.php when I am removing the text areas code from the 2nd code, particularly when I'm removing this code:
<input type='textarea' name='staffname'>
</td><td>
<input type='textarea' name='Time'>
</td><td>
<input type='textarea' name='custdetail'>
</td><td>
<input type='textarea' name='orderId'>
CODE 1 (PHP CODE):
echo "";
echo "<tr>";
echo "<td>idSpatula</td><td>Qauntity</td><td>Staff Name</td><td>Staff Id</td><td>Customer Details</d><td>Order Id</td>";
echo "</tr>";
echo "<tr>";
echo "<form >";
echo "<td>" ."Spatula Id=3"."</td><td>
<input type='textarea' name='3'>
</td><td>
<input type='textarea' name='staffname'>
</td><td>
<input type='textarea' name='Time'>
</td><td>
<input type='textarea' name='custdetail'>
</td><td>
<input type='textarea' name='orderId'>
<input type='submit' id='submit' value='submit'>
</td>
</form>";
echo "</tr>";
echo "</table>";
echo "</br>";
if(isset($_GET['3'])){
// means submit clicked!
$queryy3=0;
$queryy3 = $_GET['3'];
header('Location: mypage1.php');
$sqll3 = "UPDATE Spatula SET QuantityInStock=QuantityInStock-$queryy3 WHERE idSpatula=3 and QuantityInStock>0";
$sqlorder3 = "insert into `Order`(idOrder, RequestedTime, ResponsibleStaffMember, CustomerDetails) values (3,'1987-04-20 11:34:09','Shubhams','tell')";
$result1003 = mysqli_query($con, "SELECT QuantityInStock FROM Spatula where idSpatula=3");
mysqli_query($con, $sqlorder2);
if (mysqli_query($con, $sqll3) & $col1003['QuantityInStock']!=0 ) {
//$sql = "UPDATE Spatula SET QuantityInStock=QuantityInStock-$query WHERE idSpatula= and QuantityInStock>0";
echo "Updated";
}
while($col1003 = mysqli_fetch_array($result1003)) {
echo $col1003['QuantityInStock'];
if ($col1003['QuantityInStock']<=0){
header('Location: mypage2.php');
}
}
}
CODE 2:
echo "<table border='1'>";
echo "<tr>";
echo "<td>idSpatula</td><td>Qauntity</td><td>Staff Name</td><td>Staff Id</td><td>Customer Details</d><td>Order Id</td>";
echo "</tr>";
echo "<tr>";
echo "<form >";
echo "<td>" ."Spatula Id=4"."</td><td>
<input type='textarea' name='4'>
</td><td>
<input type='textarea' name='staffname'>
</td><td>
<input type='textarea' name='Time'>
</td><td>
<input type='textarea' name='custdetail'>
</td><td>
<input type='textarea' name='orderId'>
</td>
<input type='submit' id='submit' value='submit'>
</form>";
echo "</tr>";
echo "</table>";
if(isset($_GET['4'])){
// means submit clicked!
$queryy4=0;
$queryy4 = $_GET['4'];
header('Location: mypage1.php');
$sqll4 = "UPDATE Spatula SET QuantityInStock=QuantityInStock-$queryy4 WHERE idSpatula=4 and QuantityInStock>0";
$sqlorder4 = "insert into `Order`(idOrder, RequestedTime, ResponsibleStaffMember, CustomerDetails) values (5,'1987-04-20 11:34:09','Shusss','tss')";
$result1004 = mysqli_query($con, "SELECT QuantityInStock FROM Spatula where idSpatula=4");
mysqli_query($con, $sqlorder4);
if (mysqli_query($con, $sqll4) & $col1004['QuantityInStock']!=0 ) {
echo "Updated";
}
while($col1004 = mysqli_fetch_array($result1004)) {
echo $col1004['QuantityInStock'];
if ($col1004['QuantityInStock']<=0){
header('Location: mypage2.php');
}
}
}

Why does mysqli queries return false?

The code below is supposed to allow you to view a list of friends
and edit or delete from the same page. The viewing works, but the deleting and updating does not. Any help would be appreciated.
View code:
$query ="SELECT * FROM tblFriends";
$result = mysqli_query($conn,$query);
while($row =$result->fetch_assoc()){
$fname=$row['fname'];
$lname=$row['lname'];
$address=$row['address'];
$desc=$row['description'];
$zip=$row['zip'];
$city=$row['city'];
$state=$row['state'];
$id =$row['key'];
echo
"<tr>
<td><input type='text' name='fname' value='$fname'/></td>
<td><input type='text' name='lname' value='$lname'/></td>
<td><input type='text' name='address' value='$address'/></td>
<td><input type='text' name='city' value='$city'/></td>
<td><input type='text' name='desc' value='$desc'/></td>
<td><input type='text' name='state' value='$state'/></td>
<td><input type='submit' name='Edit' value='Edit'/></td>
<td><input type='submit' name='Delete' value='Delete'/></td>
<input type='hidden' name='id' value='$id'/>
<input type='hidden' name='zip' value='$zip'/>
</tr>";
}
Update Code:
if(isset($_POST['Edit'])){
$fname1=$_POST['fname'];
$lname1=$_POST['lname'];
$city1=$_POST['city'];
$state1=$_POST['state'];
$zip1=$_POST['zip'];
$desc1=$_POST['desc'];
$address1=$_POST['address'];
$id1=$_POST['id'];
$UpdateQuery ="UPDATE tblfriends SET fname='$fname1', lname='$lname1',city='$city1',address='$address1',zip='$zip1',state='$state1' WHERE id=$id1";
echo $id1;
if( mysqli_query($conn,$UpdateQuery)){
echo "Updated";
}else{
echo "Not Updated";
}
}
Delete Code:
This mysqli_query and the update one both return false
if(isset($_POST['Delete'])){
$id2 =$_POST['id'];
$deleteQuery= "DELETE FROM tblfriends WHERE id=$id2";
if( mysqli_query($conn,$deleteQuery)){
echo "Deleted";
}else{
echo "Not Deleted";
}
Ive looked throug your quesry lol, SPOT the odd one out?
$id =$row['key'];
"UPDATE tblfriends SET fname='$fname1', lname='$lname1',city='$city1',address='$address1',zip='$zip1',state='$state1' WHERE id=$id1
"DELETE FROM tblfriends WHERE id=$id2";
Just to help you out, your id name is key? but your checking if id matched id? Not sure but that might be your problem
So change your query to this
$query ="SELECT * FROM tblFriends";
$result = mysqli_query($conn,$query);
while($row = $result->fetch_assoc()){
$fname=$row['fname'];
$lname=$row['lname'];
$address=$row['address'];
$desc=$row['description'];
$zip=$row['zip'];
$city=$row['city'];
$state=$row['state'];
$id =$row['key'];
/**
**Wrapped your input into a form which will post the request
**/
echo
"
<form action=\"#\" method=\"POST\">
<tr>
<td><input type='text' name='fname' value='$fname'/></td>
<td><input type='text' name='lname' value='$lname'/></td>
<td><input type='text' name='address' value='$address'/></td>
<td><input type='text' name='city' value='$city'/></td>
<td><input type='text' name='desc' value='$desc'/></td>
<td><input type='text' name='state' value='$state'/></td>
<td><input type='submit' name='Edit' value='Edit'/></td>
<td><input type='submit' name='Delete' value='Delete'/></td>
<input type='hidden' name='id' value='$id'/>
<input type='hidden' name='zip' value='$zip'/>
</tr>
<br>
</form>
";
};
if(isset($_POST['Edit'])){
$fname1= $_POST['fname'];
$lname1= $_POST['lname'];
$city1= $_POST['city'];
$state1= $_POST['state'];
$zip1= $_POST['zip'];
$desc1= $_POST['desc'];
$address1= $_POST['address'];
$id1= $_POST['id'];
/**
**Updated your query to match the key rather than ID. `key`
**/
$UpdateQuery ="UPDATE tblfriends SET fname='$fname1', lname='$lname1',city='$city1',address='$address1',zip='$zip1',state='$state1' WHERE `key` = '$id1' ";
echo $id1;
if( mysqli_query($conn,$UpdateQuery)){
echo "Updated";
}else{
echo "Not Updated";
};
};
if(isset($_POST['Delete'])){
$id2 = $_POST['id'];
/**
**Updated your query to match the key rather than ID. `key`
**/
$deleteQuery= "DELETE FROM tblfriends WHERE `key` = '$id2' ";
if( mysqli_query($conn,$deleteQuery)){
echo "Deleted";
}else{
echo "Not Deleted";
}
};
Change this query "DELETE FROM tblfriends WHERE id=$id2" with "DELETE FROM tblfriends WHERE id='$id2'". Better if you check your query by run it in query editor (like phpmyadmin in tab sql).
Try testing like this in your code:
$deleteQuery= "DELETE FROM tblfriends WHERE id=$id2";
die($deleteQuery);
then copy the result that shown in browser, then paste in phpmyadmin. run it there. Hopefully it can help you

php: Using <form> tag to sum a new value to an existing value in php

I am creating a webpage that is similar to a points system. It consists of a table with name and points columns. The user inputs a number, which then adds that value to the existing number in the table. My question is how would I be able to add those two values and update the table(database)?
<?php
$con = mysql_connect("xxx, xxx, xxx);
if (!$con) {
die("can not connect:" . mysql_error());
}
mysql_select_db("points", $con);
if(isset($_POST['update'])){
$UpdateQuery = "UPDATE coach_tbl set coachscore = coachscore + '$add' WHERE coach_score = '$_POST[hidden]'";
mysql_query($UpdateQuery, $con);
};
if (isset($_POST['submit'])){
$AddQuery = "INSERT INTO coach_tbl (coach_name, coach_score) VALUES('$_POST[name]', '$_POST[score]')";
mysql_query($AddQuery, $con);
};
$sql = "SELECT * FROM coach_tbl ORDER BY coach_score DESC";
echo "<table border=1>
<tr>
<th>NAME</th>
<th>Score</th>
</tr>";
$myData = mysql_query($sql, $con);
while($record = mysql_fetch_array($myData)) {
echo "<form action=index.php method=post>";
echo "<tr>";
echo "<td><input type=text name=coachname value='" . $record['coach_name'] . "'> </td>";
echo "<td><input type=text name=coachscore value='" . $record['coach_score'] . "'> </td>";
echo "<td><input type=hidden name=hidden value='" . $record['coach_score'] . "'> </td>";
echo "<td><input type=submit name=update value=update'" . "'> </td>";
echo "<td><input type=number min="1" max="10" name=add value=add'" . "'> </td>";
echo "</tr>";
echo "</form>";
}
echo "</table>";
mysql_close($con);
?>
If there are any questions I will gladly elaborate on anything. I am also fairly new to php.
Let's say you have an html form like so:
<form action="update.php" method="POST">
<input type="number" name="updateData" value=""/>
<input type="submit">
</form>
and an update.php:
<?php
//assuming you want 1-10 points max to be added each time
if( isset($_POST['updateData']) && $_POST['updateData'] >=1 && $_POST['updateData'] >=10){
//set to user inputed value
$insertData = $_POST['updateData'];
$sql = "UPDATE point_table SET points = points + $insertData WHERE id = 1";
//you will need to finish off the query by checking connecting with your database.
}
?>

php html return only one set of data records when clicking the view button

I need my system to show only the set of 'minutes' a user clicks on and not every set of minutes that the current user is involved in.
At the minute when I click the 'image' to view a set of minutes it prints out each set of minutes that user is involved in, I need it to only print out and be able to edit that one specific set of minutes... the edit function works but I just need it to print out what the user clicks on and not every set..PLEASE Can ANYONE help with this I have spent all day and don't understand how to get this to work.
Below is the code that shows the php and query in the minutes.php page, when you click the image for 'view' it takes you to the 'viewstudentminutes.php' page, I only want it to print out the minutes you click on not every set.
<?php
session_start();
if (!(isset($_SESSION["sess_username"]))) header ("Location: index.php");
$currentUser=$_SESSION["sess_username"];
$dbQuery = $db->prepare("select * from minute where '$currentUser'=B_number ");
$dbQuery->execute();
$numMinutes = $dbQuery->rowCount();
echo "<p>There are $numMinutes sets of minutes in the system</p>";
$oddRow=true;
while ($dbRow = $dbQuery->fetch(PDO::FETCH_ASSOC)) {
$ID = $dbRow['ID'];
$B_number = $dbRow['B_number'];
$Date = $dbRow['Date'];
$Time = $dbRow['Time'];
$Discussion = $dbRow['Discussion'];
$Actions = $dbRow['Actions'];
$Dateofnextmeeting = $dbRow['Dateofnextmeeting'];
$Status = $dbRow['Status'];
$E_number = $dbRow['E_number'];
$Supervisor_comments = $dbRow['Supervisor_comments'];
if ($oddRow) $rowClass="odd"; else $rowClass="even";
$oddRow=!$oddRow;
if (isset($_POST['editMinuteID']) && $_POST['editMinuteID']==$ID) {
echo "<tr class='$rowClass '>
<form style='display:inline' method='post' action='minutes.php'>
<input type='hidden' name='editCommitID' value='$ID'>
<td><input type='varchar' name='editB_number' value='$B_number'></td>
<td><input type='date' name='editDate' value='$Date'></td>
<td><input type='time' name='editTime' value='$Time'></td>
<td><input type='text' name='editDiscussion' value='$Discussion'></td>
<td><input type='text' name='editActions' value='$Actions'> </td>
<td><input type='date' name='editDateofnextmeeting' value='$Dateofnextmeeting'></td>
<td><input type='enum' name='editStatus' value='$Status'> </td>
<td><input type='varchar' name='editE_number' value='$E_number'></td>
<td><input type='text' name='editSupervisor_comments' value='$Supervisor_comments'></td>
<td colspan='2'><input type='image' src='edit.png'>
</form>
</tr>";
} else {
echo "<tr class='$rowClass'><td>$B_number</td><td>$Date</td> <td>$Time</td><td>$Discussion</td><td>$Actions</td><td>$Dateofnextmeeting</td> <td>$Status</td><td>$E_number</td><td>$Supervisor_comments</td>
echo "<tr class='$rowClass'><td>$B_number</td><td>$Date</td><td>$Time</td><td>$Discussion</td><td>$Actions</td><td>$Dateofnextmeeting</td><td>$Status</td><td>$E_number</td><td>$Supervisor_comments</td>
<td class='operation'>
<form class='display:inline' method='post' action='viewstudentminutes.php'>
<input type='hidden' name='editMinute_ID' value='$ID'>
<input type='image' src='edit.png' style='padding-top:7px'>
</form></td>
<td class='operation'>
<form class='display:inline' method='post' action='minutes.php'
onsubmit='return confirm(\"Are you sure?\")'>
<input type='hidden' name='deleteMinuteID' value='$ID'>
<input type='image' src='delete.png' style='padding-top:7px'>
</form></td>
<td class='operation'>
<form class='display:inline' method='post' action='viewstudentminutes.php'
onsubmit='viewstudentminutes.php'>
<input type='image' src='view.png' style='padding-top:7px'>
</form></td>
</tr>";
}
}
?>
Below is the code for the 'viewstudentminutes.php' when trying to edit the set of minutes
<h2>Minutes</h2>
<table class="table table-condensed">
<?php
$dbQuery= $db->prepare("SELECT * FROM `Minute` WHERE `B_number` = '" . $currentUser . "' AND `id` = " . $_POST['Minute_ID']);
$dbQuery->execute();
$oddRow=true;
while ($dbRow = $dbQuery->fetch(PDO::FETCH_ASSOC)) {
$ID = $dbRow['ID'];
$B_number = $dbRow['B_number'];
$Date = $dbRow['Date'];
$Time = $dbRow['Time'];
$Discussion = $dbRow['Discussion'];
$Actions = $dbRow['Actions'];
$Dateofnextmeeting = $dbRow['Dateofnextmeeting'];
$Status = $dbRow['Status'];
$E_number = $dbRow['E_number'];
$Supervisor_comments = $dbRow['Supervisor_comments'];
if ($oddRow) $rowClass="odd"; else $rowClass="even";
$oddRow=!$oddRow;
if (isset($_POST['editMinuteID']) && $_POST['editMinuteID']==$id) {
echo "<tr class='$rowClass'>
<form style='display:inline' method='post' action='viewstudentminutes.php'>
<input type='hidden' name='editCommitID' value='$ID'>
<tr><td colspan='2'><input type='image' src='edit.png'> </tr>
<tr><th>BNumber</th><td><input type='varchar' name='editB_number' value='$B_number'></td></tr>
<tr><th>Date</th><td><input type='date' name='editDate' value='$Date'></td></tr>
<tr><th>Time</th><td><input type='time' name='editTime' value='$Time'></td></tr>
<tr><th>Discussion</th><td><input type='text' name='editDiscussion' value='$Discussion'></td></tr>
<tr><th>Actions</th><td><input type='text' name='editActions' value='$Actions'></td></tr>
<tr><th>Date of Next Meeting</th><td><input type='date' name='editDateofnextmeeting' value='$Dateofnextmeeting'></td></tr>
<tr><th>Status</th><td><input type='enum' name='editStatus' value='$Status'></td></tr>
<tr><th>E Number</th><td><input type='varchar' name='editE_number' value='$E_number'></td></tr>
<tr><th>Supervisor Comments</th><td><input type='text' name='editSupervisor_comments' value='$Supervisor_comments'></td></tr>
</form>
</tr>";
} else {
echo "<tr class='$rowClass'>
<td class='operation'>
<form class='display:inline' method='post' action='viewstudentminutes.php'>
<input type='hidden' name='editMinute_ID' value='$ID'>
<input type='image' src='edit.png' style='padding-top:7px'>
</form></td>
<tr><th>BNumber</th><td>$B_number</td></tr>
<tr><th>Date</th><td>$Date</td></tr>
<tr><th>Time</th><td>$Time</td></tr>
<tr><th>Discussion</th><td>$Discussion</td></tr>
<tr><th>Actions</th><td>$Actions</td></tr>
<tr><th>Date of Next Meeting</th><td>$Dateofnextmeeting</td></tr>
<tr><th>Status</th><td>$Status</td></tr>
<tr><th>E Number</th><td>$E_number</td></tr>
<tr><th>Supervisor Comments</th><td>$Supervisor_comments</td></tr>
</tr>";
}
}
?>
</table>
The Minute table within the database holds the following fields...
1 ID Primary int(10) AUTO_INCREMENT
2 B_number varchar(15) latin1_swedish_ci
3 Date date
4 Time time
5 Discussion text latin1_swedish_ci
6 Actions text latin1_swedish_ci
7 Dateofnextmeeting date
8 Status enum('Submitted', 'Approved', 'Rejected', '') latin1_swedish_ci
9 Supervisor_comments text latin1_swedish_ci
10 E_number varchar(15) latin1_swedish_ci
Please help :(
There are a few variables that I'm unsure of what they are - updating your question to include what $currentUser is would help.
That said, the issue may be in your SQL statement:
$db->prepare("select * from minute where '$currentUser'=B_number ");
You are selecting where $currentUser is equal to B_number. But in your database schema, you show that B_number is a column.
I'd try this SQL statement instead:
$db->prepare("SELECT * FROM `Minute` WHERE `B_number` = '" . $currentUser . "' AND `id` = " . $yourIDVariable );
Edit
Your viewstudentminutes.php will iterate over every record returned in your SQL query. You need to uniquely identify your Minute record to show just one on your viewstudentminutes.php page. You access this page via clicking on an <img> tag. But you never send data for which Minute object you want with this form. You could add this via:
<form class='display:inline' method='post' action='viewstudentminutes.php' onsubmit='viewstudentminutes.php'>
<input type='image' src='view.png' style='padding-top:7px'>
<input type='hidden' name='minute_id' value='" . $ID . "'>
</form>
Then access this on your viewstudentminutes.php as
$db->prepare("SELECT * FROM `Minute` WHERE `B_number` = '" . $currentUser . "' AND `id` = " . $_POST['minute_id']);

Adding Confirmation box

I'm trying to add an "confirmation box" that says "Are you sure you want to update/delete question?" when I click on my "update" and/or "delete" buttons.
I've already tried adding
onclick="return confirm('Are you sure you want to logout?');"
<input type="submit" value="Add Question" onclick="return confirm('Are you sure you want to update/delete question?');">
I provided my two php files. Might not need the whole files but I hope you can understand my issue and help the best that y'all can. thank you.
File: questions_menu.php
<?php
$username = "root";
$password = "";
$hostname = "localhost";
$database = "basketball_database";
$table = "question_bank";
$con = mysql_connect($hostname, $username, $password)
or die("Unable to connect to MYsql");
//echo "Connected to mysql<br>";
mysql_select_db("$database")
or die("Could not select Basketball_database");
//echo "Connected to database";
//update when update button pressed
if(isset($_POST['update'])){
$UpdateQuery = "UPDATE $table SET question_description='$_POST[description]', option_a='$_POST[option1]', option_b='$_POST[option2]', option_c='$_POST[option3]', answer='$_POST[dropdown]', question_id='$_POST[questionID]' WHERE question_id='$_POST[hidden]'";
mysql_query($UpdateQuery, $con);
};//end of if statement
//delete when delete button pressed
if(isset($_POST['delete'])){
$DeleteQuery = "DELETE FROM $table WHERE question_id='$_POST[hidden]'";
mysql_query($DeleteQuery, $con);
};//end of if statement
$mysql = "SELECT * FROM $table";
$mydata = mysql_query($mysql,$con);
//create table
echo "<table border=1
<tr>
<th>Question ID</th>
<th>Question Description</th>
<th>Option 1</th>
<th>Option 2</th>
<th>Option 3</th>
<th>Answer</th>
<th>Picture</th>
<th>Video</th>
</tr>";
//insert data into rows
while($records = mysql_fetch_array($mydata)){
echo "<form action=questions_menu.php method=post>";
echo "<tr>";
echo "<td>"."<input type=text name=questionID size=10 value=".$records['question_id']." </td>";
echo "<td>"."<textarea name=description rows=2 cols=25>".$records['question_description']."</textarea>"."</td>";
echo "<td>"."<input type=text name=option1 size=18 value=".$records['option_a']." </td>";
echo "<td>"."<input type=text name=option2 size=15 value=".$records['option_b']." </td>";
echo "<td>"."<input type=text name=option3 size= 15 value=".$records['option_c']." </td>";
echo "<td>"."<input type=text name=answer size=15 value=".$records['answer']." </td>";
echo "<td>"."<input type=hidden name=hidden value=".$records['question_id']." </td>";
//update button
echo "<td>"."<input type=submit name=update value=Update onclick=return confirm(Are you sure you want to update/delete question?)"." </td>";
//delete button
echo "<td>"."<input type=submit name=delete value=Delete onclick=return confirm(Are you sure you want to update/delete question?)"." </td>";
echo "</tr>";
echo "</form>";//end form
} echo "</table>";
mysql_close();
?> <!-- End of php code-->
You need to close input tag at following line:
echo "<td>"."<input type=submit name=update value=Update onclick='return confirm(\"Are you sure you want to update/delete question?\")'>"." </td>";
---------------------------------------------------------------------------------------------------------------------------------------^
And you need to use put confirm code in single quotes as shown above. And also note the escape sequence used for message text.

Categories