Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8099899
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T22:33:44+00:00 2026-06-05T22:33:44+00:00

I have a members site where users are given up to 7 web page

  • 0

I have a members site where users are given up to 7 web page templates to display their products on. Each template has the same field names, differentiated by _1, _2… _7 at the end of each.

For example:

// Template 1 would have the following list of variables
product_name_1
product_descript_1
product_color_1
product_price_1

// Template 2 would have the following list of variables
product_name_2
product_descript_2
product_color_2
product_price_2

// through Template 7

I am able to display any variables for a specific user within a web page, by use of a query string identifying their user_id in the url, ie

http://domain.com/folder/page.php?id=78

I then $_Get any variable by simply identifying it in the PHP file, ie

$product_name_1
$product_descript_1
$product_color_1
$product_price_1

My problem is that the url must identify WHICH template, since each template identifies a specific product, ie _1, _2, …_7. How do I use a parameter in the url, such as

http://domain.com/folder/page.php?id=78&parameter=_7

…to identify all variables ending with _7, which would appear in the web page? The parameter used in the url would identify the variables to be used in the web page, whether _1, _2, etc.

UPDATE

I have tried the various answers with only partial success, ie “Array_x” is displayed when using any particular variable along with the suggested code. There may be a conflict with the rest of the code I’m using in page.php, as follows:

$db_connection = new mysqli("", "", "");
if ($db_connection->connect_errno) {
   echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
}

$id = $_GET['id']; 
$query = mysql_query("SELECT * FROM table_name WHERE id = '$id' LIMIT 1") or die(mysql_error()); 
$row = mysql_fetch_object($query);

$prop_address=array(
"_1"=>"prop_address_1",
"_2"=>"prop_address_2",
"_3"=>"prop_address_3"
//Through to Temp 7
);

$prop_address{$_GET['parameter']}=$row->prop_address;

    echo " $prop_address{$_GET['parameter']} ";

“Array_x” displays (where x=1, 2, 3, etc is used as the parameter in url, ie http://domain.com/page.php?id=72&parameter=1), instead of the actual value held in the database table for $product_name{$_GET['parameter']}. For some reason, the code is not picking up the value of the variable from the database table.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T22:33:47+00:00Added an answer on June 5, 2026 at 10:33 pm

    I couldn’t get any of the answers given to work. I found an example given by a user for php variable variables in the PHP manual here and found it to work. I incorporated it into my code as follows:

      $id = $_GET['id']; 
      $query = mysql_query("SELECT * FROM table_name WHERE id = '$id' LIMIT 1") or die(mysql_error()); 
      $row = mysql_fetch_object($query);
    
      for( $i = 1; $i < 8; $i++ )
      {
      $product_name[$_GET['parameter']] = "product_name_" . $i; 
      $product_descript[$_GET['parameter']] = "product_descript_" . $i; 
      $product_color[$_GET['parameter']] = "product_color_" . $i; 
      $product_price[$_GET['parameter']] = "product_price_" . $i; 
      }
      ${$product_name[1]}  = "$row->product_name_1"; 
      ${$product_name[2]}  = "$row->product_name_2"; 
      ${$product_name[3]}  = "$row->product_name_3"; 
      ${$product_name[4]}  = "$row->product_name_4"; 
      ${$product_name[5]}  = "$row->product_name_5"; 
      ${$product_name[6]}  = "$row->product_name_6"; 
      ${$product_name[7]}  = "$row->product_name_7"; 
    
      // List 7 variables and values for each field name
    
      echo "${$prop_name[$_GET['par']]}";
    

    The only problem is that mysql injection is possible with this code. If anyone could suggest a solution, I would greatly appreciate it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a members only area on my site where users can login and
If I have a website where users login and logout, and each user has
I have a daemon that does the following retrieves site members from a mysql
I have more than 3000 members on a site built using wordpress. I am
I am trying to use paypal ipn to have members on my site buy
I have a site which houses many various directories (such as admins, members, demo
I have a Web application and a WCF service hosted on the same Windows
On shopping sites users are given recommendations based on their purchasing habits, on dating
Let us suppose I have a site with a certain number of users with
On a standard web signup form, users are required to have a unique email

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.