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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:55:21+00:00 2026-05-13T20:55:21+00:00

I have a html file that has invoice details I would like to know

  • 0

I have a html file that has invoice details

I would like to know is there a way that I can retrieve only the invoice numbers and store it separately in my sql database using php?

<p>Invoice ID: 0201</p>
<p>MID : Q987</p>
<p>Desciption: Solid Concrete Blocks</p>
<p>Qty: 7478 Blocks </p>
<p>&nbsp;</p>
<p>Invoice ID: 0324</p>
<p>MID : Q443</p>
<p>Desciption: Window Slides with Chrome </p>
<p>Qty: 33 Units </p>
  • 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-13T20:55:21+00:00Added an answer on May 13, 2026 at 8:55 pm

    You can try something like this to extract all the invoice numbers:

    <?php
    
    $input = "<body> 
    <p>Invoice ID: 0201</p> 
    <p>MID : Q987</p> 
    <p>Desciption: Solid Concrete Blocks</p> 
    <p>Qty: 7478 Blocks </p> 
    
    <p> </p> 
    <p>Invoice ID: 0324</p> 
    <p>MID : Q443</p> 
    <p>Desciption: Window Slides with Chrome </p> 
    <p>Qty: 33 Units </p> 
    </body>";
    
    $invoice_ids = array();
    if(preg_match_all('{<p>Invoice ID:\s*(\d+)</p>}',$input,$matches)) {
        $invoice_ids = $matches[1];
    }
    
    var_dump($invoice_ids);
    
    ?>
    

    Output:

    array(2) {
      [0]=>
      string(4) "0201"
      [1]=>
      string(4) "0324"
    }
    

    Once you have extracted all the invoice numbers you can insert them in a database table using something like:

    <?php
    $con = mysql_connect("localhost","USRNAME","PASSWD");
    if (!$con) {
        die('Could not connect: ' . mysql_error());
    }
    
    mysql_select_db("DB_NAME", $con);
    
    foreach($invoice_ids as $id) {
    
        $query = "INSERT INTO YOUR_TABLE_NAME(invoice_num) VALUES $id";
    
        if(!mysql_query($query,$con)) {
            die('Error: ' . mysql_error());
        }
    
    }
    mysql_close($con)
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a big HTML file that has lots of markup that looks like
I have a HTML file that has code similar to the following. <table> <tr>
I have two files: master/newsletter1/file.html master/newsletter2/file.html newsletter1/file.html has a lot of new changes that
I have a script that generates a temporary HTML file that has links to
I have an HTML file that has a set of divs with the class
I have a Python script that will look at an HTML file that has
I have a folder on a hosted web server that has an index.html file
I have a .js.erb file that has the following line $(#<%= user#{current_user.id}_following %>).html(<%= escape_javascript(link_to(pluralize(@count,'tag'),
I have an html file that has a table of information and I'm trying
Say i have a .html file that contains a web design and has variables

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.