PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Fri Dec 19, 2014 5:42 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Mon Jul 23, 2012 12:10 am 
Offline
Forum Newbie

Joined: Sat Jul 14, 2012 3:05 pm
Posts: 2
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:
Syntax: [ Download ] [ Hide ]
            <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 - $tmb\n</b><br>";}?>
</div>


I've tried to add this to the echo but it brakes the code.
Code:

Syntax: [ Download ] [ Hide ]
 
  echo "<b>$title - $description - $tmb <input name="delete" type="button" value=" ">\n</b><br>";}?>
</div>


Thank in advance.


Last edited by Benjamin on Mon Jul 23, 2012 12:59 am, edited 1 time in total.
Added [syntax=php||htm||css||javascript||sql||etc] - Please use [syntax] tags when posting code in the forums! Thanks.


Top
 Profile  
 
PostPosted: Mon Jul 23, 2012 4:32 am 
Offline
DevNet Master
User avatar

Joined: Sun Feb 15, 2009 12:08 pm
Posts: 2775
Location: .za
Syntax: [ Download ] [ Hide ]
echo "<b>$title - $description - $tmb <input name="delete" type="button" value=" ">\n</b><br>";}?>
</div>

You have to escape the double quotation marks in the string; in the snippet above the php is parsed until the next " is reached, which in the case isn't the end of the statement (marked by a ; ) so you receive an error
Syntax: [ Download ] [ Hide ]
<?php
echo "<b>$title - $description - $tmb <input name=\"delete\" type=\"button\" value=\" \">\n</b><br>";}?> </div>
?>

_________________
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering


Top
 Profile  
 
PostPosted: Mon Jul 23, 2012 12:27 pm 
Offline
Jack of Zircons
User avatar

Joined: Thu Nov 09, 2006 9:30 pm
Posts: 4484
Location: California, USA
Or, if you don't like to enter all those escape backslashes, you can use single quotes within the double quotes:
Syntax: [ Download ] [ Hide ]
echo "<b>$title - $description - $tmb <input name='delete' type='button' value=' '>\n</b><br />";}?>


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group