macattack Posted June 11, 2008 Share Posted June 11, 2008 Hello, I have a code that scans through a directory for all the blog posts I have, and in the blog editor, it will not display properly. The scanning and including is working, because I can see the blog name, but the code won't generate the link properly, and won't generate the form under it. Here's the code in question: <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>" The table is opened and closed in an external file, and the scan function is above this, but they shouldn't be the problem, as the files are being found. The link that is output ends up as "index.php?blog=example/directory/filename.php", whereas it should be "index.php?edit=EditIt&view=true&blog=example/directory/filename.php", also the form that should generate does not appear. Here's the HTML source code for the section from Safari <h2>Edit/Delete Blog Entries</h2> <table cols='2'> <a href="index.php?blog=../blogs/2008/06/10/test1.php">test1</a><br> <a href="index.php?blog=../blogs/2008/06/10/test2.php">test2</a><br> <a href="index.php?blog=../blogs/2008/06/10/test3.php">test3</a><br> <a href="index.php?blog=../blogs/2008/06/10/test4.php">test4</a><br> <a href="index.php?blog=../blogs/2008/06/10/test5.php">test5</a><br> </table> As you can see, the link is being generated incorrectly, and it's putting in <br> tags instead of </td></tr>. This occurrence seems mysterious to me. I've also tried clearing the cache, to no avail. Does anyone have a potential solution? Thanks in advance for any help! Quote Link to comment https://forums.phpfreaks.com/topic/109703-links-and-form-not-generating/ Share on other sites More sharing options...
hamza Posted June 11, 2008 Share Posted June 11, 2008 incorrect <a href='index.php?edit=EditIt&view=true&blog=$entry>$filename</a> correct is : <a href='index.php?edit=EditIt&view=true&blog=$entry'>$filename</a> secondly you should remember this rule <form> <table> blah blah . . . . . </table> </form> for tag should be outside the table tag. take care Quote Link to comment https://forums.phpfreaks.com/topic/109703-links-and-form-not-generating/#findComment-563003 Share on other sites More sharing options...
macattack Posted June 11, 2008 Author Share Posted June 11, 2008 Thanks, I made the change in regard to the missing apostrophe in the link. However, that made no difference in the link that was being output. Even when I changed the $filename variable to anything else, the name being output didn't change! I cleared my cache and history, restarted my computer, and tried with Safari 3.1.1, Firefox 3 RC2 and IE 5 for Mac, and all three displayed the same result. No form, wrong link and br tags that weren't in the code. As for your suggestion with the form tags, they must remain where they are, as it is returning a list from an array, with each blog post requiring its own edit or delete option. I know that the code should work, I just need some help figuring out why it's generating the wrong link. Here's the entire function, I'm wondering if the issue lies somewhere else? 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); $filename = $path['filename']; $linkAddress = "index.php?edit=List&view=true&blog=$entry"; $listarray[] = $path['blogs']; print ("<tr><td> <a href='$linkAddress'>$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>"); } } } It's a function that will check the directories, starting at the level YYYY then moving on to MM then DD. It should then print the specified link for each post found inside the DD directory. The posts are being returned correctly, as I've noted, but the link isn't being generated properly and the form won't appear. Quote Link to comment https://forums.phpfreaks.com/topic/109703-links-and-form-not-generating/#findComment-563032 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.