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 6366337
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:24:30+00:00 2026-05-25T00:24:30+00:00

I don’t know what is wrong with this code <?php $items = array(’00’, ’01’,

  • 0

I don’t know what is wrong with this code

<?php
  $items = array('00', '01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23');
  $time = array_search((empty($_POST['time']) ? '00' : $_POST['time']), $items) + 1; // Change '00' to whatever the default page is
  // To name the labels, you can add keys for your values like so:
  $items = array('00:00 - 01:00' => '00', '01:00 - 02:00' => '01', '02:00 - 03:00' => '02', '03:00 - 04:00' => '03', '04:00 - 05:00' => '04', '05:00 - 06:00' => '05', '06:00 - 07:00' => '06', '07:00 - 08:00' => '07', '08:00 - 09:00' => '08', '09:00 - 10:00' => '09', '10:00 - 11:00' => '10', '11:00 - 12:00' => '11', '12:00 - 13:00' => '12', '13:00 - 14:00' => '13', '14:00 - 15:00' => '14', '15:00 - 16:00' => '15', '16:00 - 17:00' => '16', '17:00 - 18:00' => '17', '18:00 - 19:00' => '18', '19:00 - 20:00' => '19', '20:00 - 21:00' => '20', '21:00 - 22:00' => '21', '22:00 - 23:00' => '22', '23:00 - 00:00' => '23');
  $time = (empty($_POST['time']) ? '00:00 - 01:00' : array_search($_POST['time'], $items)); // Replace 'home' with whatever the default page is
?>
<div data-role="fieldcontain">
  <select name="select-choice-1" id="select-choice-1">
    <option>เลือกเวลา</option> 
    <?php foreach ($items as $key => $value): ?>
      <option value="<?= $value ?>"<?= $key === $_POST['time'] ? ' ' : '' ?>> <?= $key ?></option>
    <?php endforeach; ?>
  </select>
</div>

and here is what the result of the above code

<div data-role="fieldcontain"> 
<select name="select-choice-1" id="select-choice-1"> 
<option>เลือกเวลา</option> 
<option value="00"> 00:00 - 01:00</option> 
<option value="01"> 01:00 - 02:00</option> 
<option value="02"> 02:00 - 03:00</option> 
<option value="03"> 03:00 - 04:00</option> 
<option value="04"> 04:00 - 05:00</option> 
<option value="05"> 05:00 - 06:00</option> 
<option value="06"> 06:00 - 07:00</option> 
<option value="07"> 07:00 - 08:00</option> 
<option value="08"> 08:00 - 09:00</option> 
<option value="09"> 09:00 - 10:00</option> 
<option value="10"> 10:00 - 11:00</option> 
<option value="11"> 11:00 - 12:00</option> 
<option value="12"> 12:00 - 13:00</option> 
<option value="13"> 13:00 - 14:00</option> 
<option value="14"> 14:00 - 15:00</option> 
<option value="15"> 15:00 - 16:00</option> 
<option value="16"> 16:00 - 17:00</option> 
<option value="17"> 17:00 - 18:00</option> 
<option value="18"> 18:00 - 19:00</option> 
<option value="19"> 19:00 - 20:00</option> 
<option value="20"> 20:00 - 21:00</option> 
<option value="21"> 21:00 - 22:00</option> 
<option value="22"> 22:00 - 23:00</option> 
<option value="23"> 23:00 - 00:00</option> 
</select> 
</div> 

sorry I didn’t explain it right at the first place,

what I’m trying to achieve here is that

I want to echo the time in the option

I was using <?php echo $time; ?> and this doesn’t work

I already use the value with other things

<?php echo $_POST["select-choice-1"]; ?> <<< this one been use with the other element and it display the value

Thanks

EDIT 01:

Sorry what I want is that if someone choose option value=”03″ then it will display on the the place where I want 03:00 – 04:00

  • 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-05-25T00:24:31+00:00Added an answer on May 25, 2026 at 12:24 am
    // try changing this line
    <select name="select-choice-1" id="select-choice-1">
    
    // to...
    <select name="time" id="time">
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.