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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:25:33+00:00 2026-06-14T03:25:33+00:00

Upon applying this code: $lines = explode(\n, $val); where $val = $_POST[‘result’]; and $_POST[‘result’];

  • 0

Upon applying this code: $lines = explode("\n", $val); where $val = $_POST['result']; and $_POST['result']; is from a textarea where these strings are being exploded:

A – B -> 1:00

B – A -> 1:30

So $lines[0] = "A - B -> 1:00" and $lines[1] = "B - A -> 1:30" respectively.

In foreach ($lines as $line) , I’ll explode it again for every -> meet. Like this:

    $fields = explode('->', $line);
    $loc = trim($fields[0]);
    $bltime = trim($fields[1]);

So $loc= “A – B” and $bltime = “1:00”. Then I’ll save these values in a table along with a value I stored in a session namely $_SESSION[rno] which is a primary key from another table and fetch another value from the same table.

    $e=mysql_query("select etd from reservation 
      where reservno = '$_SESSION[rno]'") or die(mysql_error());
    $f=mysql_fetch_array($e);
    $g=$f['etd'];
    mysql_query("insert into pdf(reservno, block, location, etd) 
      values ('$_SESSION[rno]', '".mysql_escape_string($bltime)."','".
      mysql_escape_string($loc)."', '$g')") or die(mysql_error()); 

Then I need to add the values of etd and block for the value of eta then just update the table having the maximum pdf_id which is the primary key of pdf table after.

    $a=mysql_query("select pdf_id as 'maxpdf' from pdf where pdf_id in 
      (select max(pdf_id) from pdf where reservno = '$_SESSION[rno]')") 
      or die(mysql_error());
    $b=mysql_fetch_array($a);
    $c=$b['maxpdf'];
    $h=mysql_query("select addtime(etd, block) as 'eta' from pdf 
      where pdf_id = '$c'") or die(mysql_error());
    $j=mysql_fetch_array($h);
    $k=$j['eta'];
    mysql_query("update pdf set eta = '$k' where pdf_id = '$c'") 
      or die(mysql_error());

So I’ll have the following values in the pdf table upon running the whole codes I posted above still based on the above value of $_POST['result'];:

enter image description here

What I want to do is to make this possible: have the first computed eta the value of the next etd then compute for it’s eta (etd + block). And then the waiting column should have the value of first eta minus the next etd. Something like this:

enter image description here

What is crucial and important here is the passing of the first eta to the next etd and the computation. How can I get it done when I’m required to loop through the exploded values? Please help me. I’m sorry for the long explanation but I want all of you to understand what I am trying to achieve. Thanks!

  • 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-14T03:25:34+00:00Added an answer on June 14, 2026 at 3:25 am

    I’ve figured out how to pass the 1st eta value to the 2nd etd and so on. Here’s the whole looping statement I used..

    $lines = explode("\n", $val);
    
    foreach ($lines as $line) 
    {
        $fields = explode('->', $line);
        $loc = trim($fields[0]);
        $bltime = trim($fields[1]);
        $e=mysql_query("select eta as 'etd' from pdf where pdf_id in (select max(pdf_id) from pdf where reservno = '$_SESSION[rno]')") or die(mysql_error());
        $f=mysql_fetch_array($e);
        $g=$f['etd'];
        if(empty($g))
        {
        $m=mysql_query("select etd from reservation where reservno = '$_SESSION[rno]'") or die(mysql_error());
        $o=mysql_fetch_array($m);
        $p=$o['etd'];
        $temp=$p;
        }
        else
        {
        $temp=$g;
        }
        mysql_query("insert into pdf(reservno, block, location, etd) values ('$_SESSION[rno]', '".mysql_escape_string($bltime)."','".mysql_escape_string($loc)."', '$temp')") or die(mysql_error());
        $a=mysql_query("select pdf_id as 'maxpdf' from pdf where pdf_id in (select max(pdf_id) from pdf where reservno = '$_SESSION[rno]')") or die(mysql_error());
        $b=mysql_fetch_array($a);
        $c=$b['maxpdf'];
        $h=mysql_query("select addtime(etd, block) as 'eta' from pdf where pdf_id = '$c'") or die(mysql_error());
        $j=mysql_fetch_array($h);
        $k=$j['eta'];
        mysql_query("update pdf set eta = '$k' where pdf_id = '$c'") or die(mysql_error());
    
    }
    

    The if(empty($g)) statement checks if the query select eta as 'etd' from pdf where pdf_id in (select max(pdf_id) from pdf where reservno = '$_SESSION[rno]') results an empty set or not. If the query results empty, then it is the first data to be inserted, therefore, $temp will hold the value of the resulted query select etd from reservation where reservno = '$_SESSION[rno]'. If otherwise, it means that there’s already data that was inputted beforehand so the $temp variable will hold the resulted query which is held by $g, so simply, $temp = $g.

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

Sidebar

Related Questions

Upon clicking on a link, I am bringing in some images from a JSON
Upon compiling and running this small program to reverse a string, I get a
In my site I am applying a stylesheet depending upon the resolution of the
Upon pre-submission review, I realize this question might be incredibly silly. if (this.gameOver(gpos) >
Upon generating a Vistual Studio project from a CMake build file, CMake generates a
I've stumbled upon something weird. When applying a dashed white border to an element,
I'm a bloody beginner with InDesign Server and stumbled upon a problem applying PDF
Upon clicking on one of the rounded rectangles in the following code, it is
Upon suggestion this question has been amended to the following; Does anyone here know
This is a follow up from Creating a class which inherits from another class

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.