hi ive been trying to sort this out all day, im very inexperianced in php but really want to do well in it and at the moment ive got a table working linked to a database and which pulls records but now i want to get an update and delete button but i cant seem to hack it heres the code.
<?php
$con = mysqli_connect("localhost","root","","lcm");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
//updates table.
if (isset($_POST['update'])){;
$UpdateQuery = "UPDATE tbl_contactinfo SET Name='$_POST[Name]', Address='$_POST[Address]' WHERE Name='$_POST[hidden]'";
mysql_query($UpdateQuery, $con);
}
if (isset($_POST['delete'])){;
$DeleteQuery = "DELETE FROM tbl_contactinfo WHERE Name='$_POST[hidden]'";
mysql_query($DeleteQuery, $con);
}
//selects the table.
$sql = "Select * from tbl_contactinfo";
if ($result = mysqli_query($con, $sql))
{
echo "<table border='1'>
<tr>
<th>Name</th>
<th>Address</th>
</tr>";
while($row = mysqli_fetch_array($result))
{
echo '<form action="index1.php" method="post">';
echo '<tr>';
echo '<td><input type="text" name="name" value="' . $row['Name'] . '" /></td>';
echo '<td><input type="text" name="address" value="' . $row['Address'] . '" /></td>';
echo '<td><input type="hidden" name="hidden" value="' . $row['ID'] . '" /></td>';
echo '<td><input type="submit" name="update" value="update" /></td>';
echo '<td><input type="submit" name="delete" value="delete" /></td>';
echo '</tr>';
echo '</form>';
}
echo "</table>";
}
?>
<html>
<body>
<form action="insert.php" method="post">
Name: <input type="text" name="Name">
Address: <input type="text" name="Address">
<input type="submit">
</form>
</body>
</html>
and error messages ive been getting.
( ! ) Notice: Undefined index: Name in C:\wamp\www\Index1.php on line 12 Call Stack # Time Memory Function Location 1 0.0000 147208 {main}( ) ..\Index1.php:0 ( ! ) Notice: Undefined index: Address in C:\wamp\www\Index1.php on line 12 Call Stack # Time Memory Function Location 1 0.0000 147208 {main}( ) ..\Index1.php:0 ( ! ) Warning: mysql_query() expects parameter 2 to be resource, object given in C:\wamp\www\Index1.php on line 13 Call Stack # Time Memory Function Location 1 0.0000 147208 {main}( ) ..\Index1.php:0 2 0.1562 154608 mysql_query ( ) ..\Index1.php:13
these are for update and for delete ( ! ) Warning: mysql_query() expects parameter 2 to be resource, object given in C:\wamp\www\Index1.php on line 18 Call Stack # Time Memory Function Location 1 0.0000 147208 {main}( ) ..\Index1.php:0 2 0.1406 154456 mysql_query ( ) ..\Index1.php:18
ive stoped the error messages before dont no how i did it but they wernt showing, only problem is when i pressed them nothing happened any help will be great.