Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP CRUD, using Javascript (PostLink) to convert href $_GET link into a $_POST
    primarykey
    data
    text
    <p>I have a MySQL database with a PHP front end. Once the user's records are queried from the database, they are displayed in a table. I created a CRUD where the user can SELECT (to view additional details), DELETE, or EDIT. The CRUD uses Javascript up to the point that the client sends the query to the DB, then redraws the index page to reflect the changes in the DB.</p> <p>I currently use a Javascript $_GET, but want to change it to a $_POST to hide the MySQL table id. I want to use something like <a href="http://code.google.com/p/postlink/" rel="nofollow">jQuery PostLink</a>. I only had a class in Java, I understand Javascript, but I am not thge best JS programmer. </p> <p>Here is the script:</p> <pre><code> &lt;script src="http://postlink.googlecode.com/svn/trunk/jquery.postlink.js" type="text/javascript" &gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; $(document).ready(function() { $('a').postlink(); }); &lt;/script&gt; </code></pre> <p>Here is the PHP code that draws my table: </p> <pre><code> foreach ($query as $row){ $id = $row['document_id']; echo ('&lt;tr&gt;'); echo ('&lt;td&gt;' . $row [clientName] . '&lt;/td&gt;'); echo ('&lt;td&gt;' . $row [documentNum] . '&lt;/td&gt;'); echo "&lt;td&gt;&lt;a href='editDocument.php?tableau={$id}'&gt;Edit&lt;/a&gt;"; echo " / "; echo "&lt;a href='#' onclick='deleteDocument( {$id} );'&gt;Delete&lt;/a&gt;&lt;/td&gt;"; // this calls Javascript function deleteDocument(id) stays on same page echo ('&lt;/tr&gt;'); } //end foreach </code></pre> <p>I do not want to have to add form tage (<code>&lt;form&gt; &lt;/form&gt;</code>) either. I want to call a script (like jQuery PostLink) that will work with the code that I have and convert href $_GET link into a $_POST. I want it to redirect to editDocument.php and have $_POST[tableau]=$id. I have been (unsuccessfully) trying to do this by "class:"</p> <pre><code>echo "&lt;td&gt;&lt;a class='postlink' href='editDocument.php?tableau={$id}'&gt;Edit&lt;/a&gt;"; </code></pre> <p>I am having 2 problems with PostLink:</p> <ol> <li>The example given converts all <code>&lt;a&gt;</code> to a $_POST (including the DELETE link). </li> <li>The lack of documentation and sample code for PostLink.</li> </ol> <p>Any thoughts???</p> <p>Thank you in advance.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload