Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP Remove one element from XML
    primarykey
    data
    text
    <p>My code should select a day from jquery datepicker, then search my xml file and display the title of matched elements in select list. When user select one item from the list, it should delete that element from xml.</p> <p>Below is my code, something is wrong with the delete part. please help [everything is done on one page deleteTask.php]</p> <p>PHP</p> <pre><code>//All tasks in Account echo "&lt;strong&gt;Delete Task&lt;/strong&gt;"; echo "&lt;br&gt;&lt;br&gt;"; echo '&lt;form action="deleteTask.php" method="post"&gt;'; echo '&lt;div&gt;'; echo '&lt;label for="date"&gt;Date &lt;/label&gt;'; echo '&lt;input type="text" id="datepicker_calender" name="date" required&gt;'; echo '&lt;/div&gt;'; echo '&lt;h1&gt;'; echo '&lt;button type="submit"&gt;Submit&lt;/button&gt;'; echo '&lt;/h1&gt;'; echo '&lt;/form&gt;'; echo "&lt;br&gt;&lt;br&gt;"; //Search task if (isset($_POST['date']) || isset($_POST['task'])) { $xml_file = simplexml_load_file("account/" . $_COOKIE["Email"] . "/" . $_COOKIE["Email"] . ".xml"); echo '&lt;form action="deleteTask.php" method="post"&gt;'; echo '&lt;select name="task" required&gt;'; foreach ($xml_file-&gt;task as $aTask) { if ($aTask-&gt;date == $_POST['date']) { echo '&lt;option value="' . $aTask-&gt;title . '"&gt;' . $aTask-&gt;title . '&lt;/option&gt;'; } } echo "&lt;/select&gt;"; echo '&lt;h1&gt;'; echo '&lt;button type="submit"&gt;Submit&lt;/button&gt;'; echo '&lt;/h1&gt;'; echo '&lt;/form&gt;'; if (isset($_POST['task'])) { foreach ($xml_file as $aTask) { if ($aTask-&gt;title == $_POST['task']) { unset($xml_file-&gt;task); } } $xml_file-&gt;saveXML("account/" . $_COOKIE["Email"] . "/" . $_COOKIE["Email"] . ".xml"); } } </code></pre> <p>XML</p> <pre><code>&lt;?xml version="1.0"?&gt; &lt;calender&gt; &lt;task&gt; &lt;date&gt;04/09/2013&lt;/date&gt; &lt;title&gt;test&lt;/title&gt; &lt;description&gt;test&lt;/description&gt; &lt;/task&gt; &lt;task&gt; &lt;date&gt;04/09/2013&lt;/date&gt; &lt;title&gt;dfn sd&lt;/title&gt; &lt;description&gt;dfsf&lt;/description&gt; &lt;/task&gt; &lt;task&gt; &lt;date&gt;04/10/2013&lt;/date&gt; &lt;title&gt;test&lt;/title&gt; &lt;description&gt;test&lt;/description&gt; &lt;/task&gt; &lt;/calender&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload