Jump to content

Search the Community

Showing results for tags 'while doloops'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start





Website URL








Donation Link

Found 1 result

  1. I'm having a bit of trouble maintaining the value of a variable within a while do loop. It seems the pointer keeps pointing to the first id no matter how many loops there are. I've inserted a hidden field which pulls in each id with shows the IDs are fine but whenever I click on 'editForm' anchor it always points to either the first or last id in the loop, (depending on whether I put the editForm div tag before or after the loop). Can anyone out there help me fix this problem? The code is shown below: $('.formEditAnchor').click(function() { $('#editMyForm').submit(); }); <?php function editFunction($editID) { $database = new database(); $res = $database->selectDB("select content as EditContent from content where id = '$editID'"); $editForm = "<form method='POST' action='_scripts/_php/edit-file.php'>"; $editForm.= "<textarea name='saveContent' cols='70' rows='25'>"; while($row = mysql_fetch_array($res)) { $row = mysql_fetch_array($res); $editableFile = $row['EditContent']; $editableContent = file($editableFile); $editableString = implode($editableContent); } $editForm.= $editableString; $editForm.= "</textarea>"; $editForm.= "<input type='hidden' name='hiddenEditPath' value='<?php echo $editableFile; ?>' />"; $editForm.= "<br />"; $editForm.= "<input type='submit' name='saveFile' value='Save'>"; $editForm.= "</form>"; return $editForm; } function submitEditForm() { if (isset($_POST['formEditAnchor'])) { $usersReplyId = $_POST['hiddenUserReplyID']; $returnEdit = editFunction($usersReplyId); return $returnEdit; } } $result3 = $database->selectDB("select * from blog_content where content_id = '$id'"); $r = array(); while($rows = mysql_fetch_array($result3)) { $myID = $rows['id']; $file = $rows['content']; $contents = file($file); $string = implode($contents); ?> <form name="editMyForm" id="editMyForm" method="post" action"<?php echo $_SERVER["PHP_SELF"]?>"> <input type="hidden" name="hiddenUserReplyID" id="hiddenUserReplyID" value="<?php echo $myID ?>" /> <table> <tr> <tr> <td bgcolor="#F8F7F1" align="center">Date/Time:<?php echo $rows['datetime']; ?></td> </tr> <tr> <td bgcolor="#f8f7f1"><?php echo $string; echo "<br /><br />"; ?> </td> </tr> <tr> <td><a href="#editContent" class="create-content" id="formEditAnchor" onclick="<?php $myReturnEdit = submitEditForm(); ?>">Edit File</a></td> </tr> </tr> </table> </form> <?php } ?> <div id='editContent' class='create-topic'> <?php echo $myReturnEdit; ?>
  • 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.