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

  • Home
  • SEARCH
  • 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 8011183
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T18:57:20+00:00 2026-06-04T18:57:20+00:00

I am trying to put the following into a php block so i can

  • 0

I am trying to put the following into a php block so i can reuse it in other webpages but i’m getting way too many errors.

can somebody please tell me how i can achieve this?

block of code inside php file:

<select name="products">
                        <option value="select">Select</option>
                        <option value="Box" <?php echo @$product_list['Box'] ?>>Box</option>
                        <option value="TV"  <?php echo @$product_list['TV'] ?>>TV</option>
                        <option value="Setup"  <?php echo @$product_list['Setup'] ?>>Setup</option>
                    </select>

I need the above code echoed inside the html page.

Thanks!

I just tried the heredoc syntax which doesn’t appear to work which must mean i’m doing something wrong sigh

EDIT:

Any idea why i would get the following error for the code below:
syntax error, unexpected T_IF

echo '<select name="products">
                        <option value="select">Select</option>
                        <option value="Box" '. 
                        if (!isset($updatebtn_clicked)){
                            echo @$product_list['Box'];
                            }elseif (isset($updatebtn_clicked)){
                            echo @$_POST['Box'];
                        }

                         .'>'. $product_name[0] .'</option>
                                    <option value="select">Select</option>
                        <option value="TV" '. 
                        if (!isset($updatebtn_clicked)){
                            echo @$product_list['TV'];
                            }elseif (isset($updatebtn_clicked)){
                            echo @$_POST['TV'];
                        }

                         .'>'. $product_name[1] .'</option>
                         </select>;
  • 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-04T18:57:21+00:00Added an answer on June 4, 2026 at 6:57 pm

    Use single quotes:

    $select = '<select name="products">
                   <option value="select">Select</option>
                   <option value="Box" ' . $product_list['Box'] . '>Box</option>
                   <option value="TV"  ' . $product_list['TV'] . '>TV</option>
                   <option value="Setup" ' . $product_list['Setup'] . '>Setup</option>
               </select>';
    echo $select;
    

    Or, close and open the PHP block:

    <?php
    
    ?>
    <select name="products">
        <option value="select">Select</option>
        <option value="Box" <?php echo @$product_list['Box'] ?>>Box</option>
        <option value="TV"  <?php echo @$product_list['TV'] ?>>TV</option>
        <option value="Setup"  <?php echo @$product_list['Setup'] ?>>Setup</option>
    </select>
    <?php
    

    Or, use output buffering:

    <?php
    ob_start();
    ?>
    <select name="products">
        <option value="select">Select</option>
        <option value="Box" <?php echo @$product_list['Box'] ?>>Box</option>
        <option value="TV"  <?php echo @$product_list['TV'] ?>>TV</option>
        <option value="Setup"  <?php echo @$product_list['Setup'] ?>>Setup</option>
    </select>
    <?php
    $select = ob_get_clean();
    echo $select;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to put the following code into VBA. What I ideally want
I'm trying to format a SOAP request with PHP. If I put the following
I'm trying to put the following logic into an Extension method that let's me
I am trying to put getters and setters into my inteface but I get
I'm trying to use smart-operator.el in emacs. I've put the following into my init.el
The following html shows a item information. I'm trying put the avaliation span on
I am trying to put together a GWT webapp following this GWT MVP tutorial
I'm trying to put together a Continuous Integration server that will do the following:
I'm trying put an if statement directly into a select field in rails, with
I'm trying to put data from this JSON object (from Google Books API) into

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.