We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 2472
    • 151 Posts
    Hi all,

    I made myself a snippet that extracts some data from a custom table and presents this data in a tabular way.

    Each row of the table contains an hyperlink to another document that should allow the user to update the data of this row and submit it back to the datbase.

    I thought i could just add the row id in the link like in ’index.php?id=55?rowid=7’, but apparently modx doesn’t like this...

    Any idea how i can retrieve the rowid 7 when i’m in document 55?

    TIA
      A thing of beauty is a joy forever ( John Keats)
    • Try &rowid=7; you can only have one ? in the URL query string (that’s an HTTP thing, not MODx). Or, try passing the value as a hidden input value. Why do you have it being passed to another document? Make the table you are displaying initially a form. You would need to generate the form so that the name of the input is like this:

      <input ... name="ValueToEdit[$rowid]" />

      thus making the input an array in the POST, with the row ID as the sub-array index.

      I used this method to make a shopping cart item quantity editable, using placeholders set in the snippet:

      <input class="text" type="text" name="scItemQuantity[[+id+]]" size="3" value="[+quantity+]" />
      


      So, if it’s item 4, the POST will contain:

      [4] -> [1]

      if the user sets the quantity of product 4 to 1.

      I read it like this:

        
      foreach($_POST['scItemQuantity'] as $key=>$value) { ...
      


      The $key is the line item ID, the $value is the value the user edited.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 2472
        • 151 Posts
        Quote from: sottwell at Dec 14, 2005, 05:40 PM

        Try &rowid=7; you can only have one ? in the URL query string (that’s an HTTP thing, not MODx). ...

        That just does the trick, thanks a lot!

        The first document just list current prices of items with an update icon that links to a second page containing the update form. The second page will retrieve aditionnal data for this item, list them in a form allowing the user to update.

        Next step, how do I retrieve the value of rowid passed as index.php?id=55&rowid=7 when i’m in the document?

        Sorry for such basic questions but this is all very new to me wink
          A thing of beauty is a joy forever ( John Keats)
          • 32241
          • 1,495 Posts
          $_GET[’rowid’]

          That’s a kinda like global array in PHP to fetch query string.

          Hope that helps.
            Wendy Novianto
            [font=Verdana]PT DJAMOER Technology Media
            [font=Verdana]Xituz Media
            • 2472
            • 151 Posts
            Yes!
            this helps me a lot indeed, thank you both for your help.

            Greetings from Belgium
              A thing of beauty is a joy forever ( John Keats)