Jump to content

Form not being printed


macattack

Recommended Posts

I have the following function

 

function displayBlogsButtons($dir = '../blogs'){
	foreach(scandir($dir) as $entry)
		if($entry != '.' && $entry != '..' && $entry != '.svc')
		{
			$entry = $dir.'/'.$entry;
			if(is_dir($entry))
			{
				$path = pathinfo($entry);
				$listarray[$path['blogs']] = listblogs($entry);
			}
			else
			{
				$path = pathinfo($entry);
				$listarray[] = $path['blogs'];	
				print ('<tr><td>
							<a href="index.php?blog=$entry&view=true">$path[\'filename\']</a>
						</td><td>
						<form action="index.php" method="post">
							<input type="hidden" name="blog" value="$entry">
							<input type="hidden" name="title" value="$path[\'filename\'>
							<input type="submit" name="edit" value="Edit">
							<input type="submit" name="delete" value="Delete">
						</form>
						</td></tr><br>
				');
			}
		}
}

 

and it should be printing that form after each entry. However, all I am seeing is the link to the post, and no form afterwards. The table is opened and closed in another function, here:

 

function displayEditDeleteBlogForm(){
	print ("<a href='..'>Editor Home</a><br>");
	print ("<h2>Edit/Delete Blog Entries</h2>");
	print ("<table>");

	displayBlogsButtons();

	print ("</table>");
}

 

the code generates no error messages and shows the links to every post, as requested. Could anyone suggest why the form won't generate?

 

Thanks in advance!

 

 

Link to comment
Share on other sites

Take a look at the HTML in the processed page. I can see at least a ouple of problems which may, or may not, be related to your specific problem.

 

For example, you are printing strngs using single quotes and you have varialbes inside the string. Variable are only interprested inside strings created with double quotes.

 

Also, you have a HTML break tag at the end of the TR closing tag for the form. It shouldn't screw up the form, but it is not valid HTML to have "content" inside a table that is not inside TD tags. There's no telling how each brower will interpret that.

 

Link to comment
Share on other sites

Thanks for your help. The quotations mistake was rather silly.

 

I've made the following modification to the code:

 

{
				$path = pathinfo($entry);
				$listarray[] = $path['blogs'];	
				$filename = $path['filename'];
				print ("<tr><td>
							<a href='index.php?edit=EditIt&view=true&blog=$entry>$filename</a>
						</td><td>
						<form action='index.php' method='post'>
							<input type='hidden' name='blog' value='$entry'>
							<input type='hidden' name='title' value='$filename'>	
							<input type='submit' name='edit' value='Edit'>
							<input type='submit' name='delete' value='Delete'>
						</form>
						</td></tr>
				");
				}
			}

 

but I've noticed two problems, and I can't figure out how to fix them. The edit=EditIt&view=true portion of the link doesn't appear, it just goes straight to the "blog" value. (outputs: index.php?blog=DIRECTORY.php). It still isn't displaying the form. I have tried in Safari and Firefox.

Link to comment
Share on other sites

The part about part of the text "disappearing" is very odd. I don't see how that could possibly happen with the code you have.

 

When I run into these types of problems I will sometimes remove all the code from the effected area and then add a line (or a few lines) back in and then test. If those linse work correctly I will ad a few more back and so on. Once it "breaks" I know the line(s) of code that are causing the problem.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.