# Getting Query String Parameters

You can reference query string parameters in Visualforce markup by using the `$CurrentPage` global variable. Using `$CurrentPage`, you can access the query string parameters for the page by specifying the `parameters` attribute, after which you can access each individual parameter:

```visualforce
$CurrentPage.parameters.parameter_name
```

For example, suppose you want to add detail information about a specific contact to an Account page. The account record ID is specified by the default `id` query string parameter, and the contact record ID is specified by the query string parameter named `cid`:

```markup
<apex:page standardController="Account">
    <apex:pageBlock title="Hello {!$User.FirstName}!">
        You are displaying values from the {!account.name} account and a separate contact
        that is specified by a query string parameter.
    </apex:pageBlock>
    <apex:pageBlock title="Contacts">
        <apex:dataTable value="{!account.Contacts}" var="contact" cellPadding="4" border="1">
              <apex:column>
               <apex:facet name="header">Name</apex:facet>
                {!contact.Name}
              </apex:column>
              <apex:column>
               <apex:facet name="header">Phone</apex:facet>
              {!contact.Phone}
              </apex:column>
        </apex:dataTable>
    </apex:pageBlock>
    <apex:detail subject="{!$CurrentPage.parameters.cid}" relatedList="false" title="false"/> 
</apex:page>
```

For this example to render properly, you must associate the Visualforce page with valid account and contact IDs in the URL. For example, if `001D000000IRt53` is the account ID and `003D000000Q0bIE` is the contact ID, the resulting URL should be:

```nolang
https://MyDomain_login_URL/apex/MyFirstPage?id=001D000000IRt53&cid=003D000000Q0bIE
```

[Displaying Field Values with Visualforce](/docs/platform/salesforce-pages-developers-guide/guide/pages-quick-start-display-field-values.md) has more information about retrieving the ID of a record.

:::note
If you use the `id` parameter in a URL, it must refer to the same entity referred to in the standard controller.
:::

![A Visualforce page that uses query string parameters](https://a.sfdcstatic.com/developer-website/sfdocs/platform/media/salesforce-pages-developers-guide/pages_quick_start_query_string_params.png "Using Query
String Parameters in a                     Page")
