/    Sign up×
Community /Pin to ProfileBookmark

adding delete button or check box to form

Greetings,

I have a form that that will upload an image with comments saving to an xml file.

The page also list all the images and comments in the xml page.

What I am having trouble with is creating a delete button or check box to delete a record in the xml file via the php form.

Here is the Form:

[code]
<form action=”playlistaction.php” method=”post” enctype=”multipart/form-data”>
<table>
<tr>
<td colspan=”2″class=”labelcell”><label for=”title”>Title:</label></td>
<td colspan=”2″class=”fieldcell”><input type=”text” id=”title” name=”title” tabindex=”1″/></td>
</tr>
<tr>
<td colspan=”2″class=”labelcell”><label for=”description”>Description:</label></td>
<td colspan=”2″class=”fieldcell”> <input type=”text” id=”description” name=”description” tabindex=”2″/><br />
</td>

<tr>
<td colspan=”2″class=”labelcell”><label for=”userfile”>Image Upload:</label></td>
<td colspan=”2″> <input name=”userfile” type=”file” id=”userfile” tabindex=”2″/><br />
</td>
</tr>

<tr style=”display:none”>
<td colspan=”2″class=”labelcell”><label for=”img”>Image</label></td>
<td colspan=”2″ class=”fieldcell”> <input type=”text” id=”img” name=”img” tabindex=”4″></td>
</tr>
</td>
</tr>
<td colspan=”4″><input type=”submit” name=”upload” class=”box” value=”Submit” tabindex=”5″ /></td>
</table>
</fieldset>
</form>
<h2>Current entries:</h2>
<p>Title – Description – Image </p>
<div style=”border:1px solid black; overflow:auto; height:400px; width:800px”>
<?php
$doc = new DOMDocument();
$doc->load( ‘photoGallery.xml’ );

$gallery = $doc->getElementsByTagName( “images” );
foreach( $gallery as $images )
{
$artists = $images->getElementsByTagName( “title” );
$title = $artists->item(0)->nodeValue;

$titles= $images->getElementsByTagName( “description” );
$description= $titles->item(0)->nodeValue;

$tmbs = $images->getElementsByTagName( “tmb” );
$tmb = $tmbs->item(0)->nodeValue;

$imgs = $images->getElementsByTagName( “img” );
$img = $imgs->item(0)->nodeValue;

echo “<b>$title – $description – $tmbn</b><br>”;}?>
</div>
[/code]

I’ve tried to add this to the echo but it brakes the code.

[code]
echo “<b>$title – $description – $tmb <input name=”delete” type=”button” value=” “>n</b><br>”;}?>
</div>
[/code]

Thank in advance.

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@myitalanauthorJul 29.2012 — Greetings,

I finally got the button at the end of the data display from my xml file. I'm surprised no one was able to figure this out...

Anyway, now that that is done

<i>
</i>echo "&lt;b&gt;$title - $description - $tmb &lt;input name="delete" type="button" value=" "&gt;n&lt;/b&gt;&lt;br&gt;";}?&gt;


I would like to place variable $title in a text boxes in order to make changes. I will be adding an update button next to the delete button.

This is what I did and of course it broke

<i>
</i>echo "&lt;b&gt;?&gt; &lt;input name="tupdate" type="text" id="tupdate" value="&lt;?php echo "$title"; ?&gt;" /&gt; - $description - $tmb &lt;input name="delete" type="button" value=" "&gt;n&lt;/b&gt;&lt;br&gt;";}?&gt;


Where am going wrong? ... redemption time!
Copy linkTweet thisAlerts:
@NogDogJul 29.2012 — Well, to start off with, this ain't gonna work:
[code=php]
echo "<b>?>
[/code]

How about just doing:
[code=php]
?><b>
[/code]

?
Copy linkTweet thisAlerts:
@mistin_caJul 29.2012 — your 2nd post ...

[code=php]
echo "<input name='tupdate' type='text' id='tupdate' value='{$title}' />
<b> - {$description} - {$tmb} </b>
<input name='delete' type='button' value=''><br>";
} ?>
[/code]
×

Success!

Help @myitalan spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.8,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...