PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
$nummer1 = "Antalet auktioner som är igång: ";
$nummer1 .= "$result";
echo "$nummer1";
I know it's not neccessary to do like above but i didn't at the beginning but i got the same error so i tryed with a diffrent setup on it but I still got the same error.
<?php
$mysql_server = "xxx";
$mysql_user = "xxx";
$mysql_password = "xxx";
$mysql_database = "xxx";
$conn = mysql_connect($mysql_server, $mysql_user, $mysql_password);
mysql_select_db($mysql_database, $conn);
$sql = "SELECT *
FROM auction
ORDER BY id DESC";
if (!$result = mysql_query($sql))
{
die("Could not get the item list: " . mysql_error());
}
echo '<form method="post" action="tabortauktion.php">';
echo '<select name="auction">';
while ($row = mysql_fetch_array($result))
{
echo '<option value="' . $row['id'] . '">' . $row['auktionnamn'] . '</option>';
}
echo '</select>';
echo "<input type='submit' name='submit' value='Få fram auktion'>";
echo '</form>';
?>
<?php
include "connect.php";
error_reporting(E_ALL);
if (isset($_POST['auction']))
{
// You would really want to validate this here,
// But I am keeping this intentionally simple
$item_id = $_POST['auction'];
$sql = "SELECT *
FROM auction
WHERE id = $item_id ORDER BY id DESC";
if (!$result = mysql_query($sql))
{
die("Could not get the selected item: " . mysql_error());
}
$item_array = mysql_fetch_array($result);
$sql2 = "SELECT * FROM bud WHERE item = $item_id";
if (!$result2 = mysql_query($sql2))
{
die("Could not get the selected item: " . mysql_error());
}
echo '<form method="post" action="tabortauktion.php">';
echo 'Ta bort denna auktion: ';
echo "<br>";
echo " Ja <input type='checkbox' name='tabort_ja' value=''" . $row['auktionnamn'] . ">";
echo "<br>";
echo '</form>';
echo "<br>";
echo "<input type='submit' name='submit' value='Få fram fakta'>";
//if($_POST['tabort_ja']) {
//$sql2 = "DELETE * FROM auction WHERE id = $item_id LIMIT 1";
//$result2 = mysql_query($sql2) or die(mysql_error());
//echo "Auktionen har blivit raderat";
//echo "<a href='admin.php'>Tillbaka till Admin Panelen</a>";
//break;
//}
if($_POST['tabort_ja'])
{
$tabort=addslashes($_POST['tabort_ja']);
mysql_unbuffered_query("DELETE FROM auction WHERE id=$tabort");
}
if(!$result=mysql_query("SELECT id,auktionnamn,item,datum_borja,maxantalbud,antalbud,bild,marknadsvarde,info,status FROM `auction` ORDER BY `id`"))echo(mysql_error());
}
?>
The checkbox got the value zero so none gets deleted. How should i solve it?
Thanks
Without looking closely, it looks like you have 2 forms. Each form should have a unique name I believe. Add name="something" to each <form .... > tag and try it again. Also add this right under <?php
That will show you what is being posted to the form. It's possible your value='' isn't being populated. You may want to right click view source to double check that.