leatherback wrote:Did you try the little snippet I posted for you?
J.
I did but that also made it not remove.
The example I was using may be the problem, I'm trying to use it in a larger bit of a code but it's quite long so I made the other example to make it easier to read.
If you have time to read through this perhaps you can see another reason it's not working
<?
//list.php
error_reporting(NONE);
include ("db_connect.php");
$dowhat=$_POST['submit'];
$filter=trim($_POST['filter']);
$order=$_POST['order'];
$usestyle=$_POST['styles'];
if(!isset($array)){
$array=array();
}
if(isset($array)){
foreach ($_POST['publications'] as $a) {
$array[]=$a;
}
}
foreach ($_POST['inarray'] as $a){
$array[]=$a;
}
$uarray=array_unique($array);
if($dowhat=="Go"){
include("dolist.php");
die();
}
if ($dowhat=="Remove"){
if(isset($_POST['addedpublications'])){
//This is where code to remove should go, but none is working :(
}
}
?>
<html>
<head>
<title>Publications Database - Create List</title>
<link href="main.css" rel="stylesheet" type="text/css">
</head>
<body class="bodystyle">
<h1 class="xbig">Publications Database - Create List</h1>
<h2 class="medium">Create a list of publications to export using this form. If you get confused about how to use it why not consult the <a href="listhelp.php">help</a>.</h2>
<br>
<form action="list.php" method="post">
<?
if(isset($array)){
foreach ($array as $a){
echo '<input name="inarray[]" type="hidden" value="' . $a . '">';
}
}
?>
<div align="left">
1) To start please choose a style to apply to this list:
<select name="styles">
<?
$stylequery=mysql_query("SELECT * FROM style");
while ($stylename = mysql_fetch_array($stylequery)){
if ($usestyle==$stylename["styleid"]){
echo '<option value ="' . $stylename["styleid"] . '" selected>' . $stylename["stylename"] . '</option>';
} else {
echo '<option value ="' . $stylename["styleid"] . '">' . $stylename["stylename"] . '</option>';
}
}
?>
</select>
<br><br><br>
2) Now please select which fields to papers to include:
<br><br>
<input name="filter" type="text"> <input name="submit" type="submit" value="Filter">
<br><br>
<table width="90%">
<tr>
<td>
<select name="publications[]" size="10" multiple>
<?
if($dowhat=="Filter"){
$docquery=mysql_query("SELECT * FROM docs WHERE title LIKE '%$filter%' order by title") or die("Fatal error: failed to run query on 'list.php' L44");
while ($docname = mysql_fetch_array($docquery)){
if(!in_array($docname["docid"], $uarray)){
echo '<option value="' . $docname["docid"] . '">' . substr($docname["title"],0,35) . ' (' . $docname["year"] . ')' . '</option>';
}
}
} else {
$docquery=mysql_query("SELECT * FROM docs");
while ($docname = mysql_fetch_array($docquery)){
if(!in_array($docname["docid"], $uarray)){
echo '<option value="' . $docname["docid"] . '">' . substr($docname["title"],0,35) . ' (' . $docname["year"] . ')' . '</option>';
}
}
}
?>
</select>
<input name="submit" type="submit" value="Add">
</td>
<td>
<select name="addedpublications[]" size="10" multiple>
<?
if(isset($uarray)){
foreach($uarray as $a){
$docinfo=mysql_fetch_array(mysql_query("SELECT * FROM docs WHERE docid='$a'"),1);
echo '<option value="' . $docinfo["docid"] . '">' . substr($docinfo["title"],0,35) . ' (' . $docinfo["year"] . ')' . '</option>';
}
}
?>
</select>
<input name="submit" type="submit" id="submit" value="Remove">
</td>
</tr>
</table>
<br><br>
3) Now choose how you would like your outputted list to be ordered:
<br><br>
Alphabetically (by title): <input name="order" type="radio" value="alphaname" <? if ($order=="alphaname"){ echo "checked"; } ?>> Alphabetically (by author): <input name="order" type="radio" value="alphaauth" <? if ($order=="alphaauth"){ echo "checked"; } ?>> Chronologically: <input name="order" type="radio" value="chron" <? if ($order=="chron"){ echo "checked"; } ?>> As selected: <input name="order" type="radio" value="as" <? if ($order=="as"){ echo "checked"; } ?>>
<br><br><br>
4) Ready to create your list?
<input name="submit" type="submit" id="submit" value="Go">
</div>
</form>
<?
include('footer.php');
?>
</body>
</html>
Thanks for all your help so far both of you though 🙂