There's a section in my website that allows to export an Excel file by clicking a button. The data displayed in the Excel file is taken from my database using SQL.
The following are examples of what is found in the column in my database:
12
34
456
2
7654
43
1234
7
Currently it displays identically as above in the Excel sheet, but what I would like would be for all the rows to have 4 digits. Therefore, data with less than 4 digits would have leading zeros added to it.
Using the same example, here is how I would like it to show in the exported Excel sheet:
0012
0034
0456
0002
7654
0043
1234
0007
This seems like a relatively simple task, but I cant seem to find how to make this happen through my research. I hope someone here will be able to help.
Thank you.
$number = str_pad($value, 4, '0', STR_PAD_LEFT);
Related
I am trying to display data extracted from PDF document. Here is sample data which I've got in raw format from pdf 55.0 450.0 320.0 GA350C CARDS 4 21 90.0 4 1 DIGCLR This is one row where every space represent one column. I can extract each column with substr() function in PHP but I am not sure how to display data when there are three or five rows data in there, cos doesn't matter its one row or five row data will display in single line.
I can only count rows with no of space in it, here only one thing is fixed which is no of columns so so need to iterate loop efficiently.
If anyone has better idea plz let me know.
Here is string which I extracted from pdf doc with help of PdfParser.
5284 25/10/16 DATE JOB REC'D: DATE DUE: 26/10/16 JOB NUMBER: The Print Group CUSTOMER NAME: 30 days CONTACT: Tanya Bulley PHONE: (07) 3395 7248 FAX: (07) 3395 9462 ORDER NUMBER: 234456/277458 ADDRESS: The Print Group 88 Webster Road Geebung Qld 4034 Australia 5,289 QUOTE NO: PREVIOUS JOB NO: 0 2,000 Business Cards - Shed Company 2 KINDS JOB: DESCRIPTION: PRE-PRESS: Supplied Print Ready Files/ No Proof Required SIZE: BC 90 x 55mm PRINTED: CMYK 2/sides STOCK: 350gsm Gloss Art FINISH:Trim to size QTY: 2000 (1,000 each name) PACK: Carton Pack DELIVERY: 1 Point ACT [1]SPECIAL INSTRUCTIONS: Artwork Received SPECIAL INSTRUCTIONS: Out on Proof Approved Stock TYPE/ART CUTTING Proofing Pre Press Proofing 0.50 TRIMMING CARDS TRIM MAKE READY CARDS TRIM 90 x 55 STOCK 96.00 CARDS Sovereign Gloss 450x320/350 FINISHING PACK/DELIVERY PACK A4 Cartons 305x215/280 Standard Local Delivery (by we INK/CHEMICALS OUTSIDE WORK Delivery: The Print Group 88 Webster Road Geebung Qld 4034 Press Sheet Press Code Stock Code No. of Work & Turn No Up No. of Colours Front Back Description Ink Code Front Back Trim Size Depth Width Ink Notes 55.0 450.0 320.0 GA350C CARDS 4 21 90.0 4 1 DIGCLR
This is basically job order for printers and last line is job details. Right now its only one row for actual job details but in some order it can go upto 10 rows and so its hard to save it in database with proper column name. To grab words or details I used:
function GetBetween($content,$start,$end)
{
$r = explode($start, $content);
if (isset($r[1])){
$r = explode($end, $r[1]);
return $r[0];
}
return '';
}
this function. I used this function like $cust_name = GetBetween($a,'JOB NUMBER:','CUSTOMER NAME:'); I also used substr() php function to get some details and with these I've got everything apart from main data which is at last in string (I mentioned it above). I hope this explanation help you to figure out whole situation.
Sorry, i try to explain with bulk of code and long description, but stackoverflow not allow me to writing that. i'm so frustated because i spend 2 hours to doing it with my notepad
now i will give you simple clue for doing this
Avoid to using <*table> tag, try to using <*div> (only abbyy can convert <*table> near perfectly). This optional requirement
Convert PDF to DOM TREE, i recommended convert to HTML, AND this must be automation via PHP.
for Paid software: Abbyy Fine reader or Abbyy transformer (lite version)
for Free software: pdftohtml from poppler
from my experience around 5years doing this, i recommended you to use
Abbyy. And ALL of Indonesian corporation which provide digital
newspaper clipping use this software (im pretty sure about this). If
you dont have money , you must know how to get that.(i cant say it
here)
Grab HTML DOM with regular expression (regex) or http://simplehtmldom.sourceforge.net/
Another clue :
if you have problem to grab content using regex/htmldom,
1. try to get rid DOM that you dont need it. You can use preg_replace
[trash]
[YOUR_TABLE]
[trash]
then start to grab your content from this snippet
If you can edit PDF creation process, try to add unique word/string around your content
[trash]
<div>this is title</div>
[YOUR TABLE]
<div>this is footer</div>
[trash]
so you can search your content around word THis is title and this is footer.
I imported products from my business software to my shop everything worked OK however it only imported part of the description when the description contained characters such as ® and other strange characters.
For example:
Data exported to Shop: X-Ring 10,82 x 1,78 mm BS013 Viton® 75 +/- 5 Shore A schwarz/black
Data imported into Shop: X-Ring 10,82 x 1,78 mm BS013 Viton
After the word Viton everything else was deleted I suppose the character ® was the problem because we are in Europe and the import program did not consider this.
My question is how can I search "Viton" and replace it with "Viton® 75 +/- 5 Shore A schwarz/black"
I cannot change the program nor am I a programmer however I do know how to do a few commands within mysql. I am looking for a command replace "&Viton&" command with "Viton® 75 +/- 5 Shore A schwarz/black"
Thank you very much for your assistance
You may want to use the HTML entity ® or as icecub suggest® , which will display as the circled R on a web page. Anyway, search replace on a single column like this
Step 1. MAKE A BACKUP OF THE TABLE!
Step 2, execute this query.
update TABLE
set `COLUMN` =
replace(`COLUMN`, 'Viton', 'Viton® 75 +/- 5 Shore A schwarz/black');
I am a little new to MYSQL and PHP so any help is much appreciated. I have a database right now that is storing ten values, a name and 9 scores. I also have an excel spreadsheet that has the names and empty slots for those 9 scores. I have a bunch of formulas that use those 9 scores to calculate other scores. Is it possible to read those 9 scores for each individual name from my database then place them into that specific slot of the spread sheet based on there name? I do not want to write to a new spread sheet but rather input these scores into that spreadsheet that is being used. Thanks in advance!
In PhpMyAdmin select your database, then export -> CSV or CSV for MS Excel
Take a look at the screenshot:
I'm developing an android application that parses json and looks for two of the same words.
For the current day.
But i'm just asking now for the best way to parse all that HTML code into Json.
So this site is in dutch. But I'll try to guide you a bit,
The top table says Maandag through vrijdag, which translated, are the days (Monday to Friday) from left to right.
I need to skip these cells. Also the cells from that say: 1, 2, 3, 4, 5 from top to bottom.
But now! The cells from the 'main' table has a table in it. So a table in a cell.
I only need the third cell from the table in the cell.
So for example:
At "Vrijdag", "1" It says: "L119"
I only need to have these together with the day and number.
so that is probably gonna be a 3D array json.
I can do further explanation if needed.
But for a conclusion:
I need a way to parse the classrooms ( ex. "L119", "D60", "S-5", "C162" ) together with the day and numbers on the left into a 3D json array.
It would be awesome if you could send the the source code but If you do so please also provide some simple explanation. I will also put your name in the credits if you want. But it will be a Dutch app.
NVM I got it myself.
If you wonder how i did it:
I used something called: "Simple_HTML_Dom.php" I used this to find the right table and content!
-Tim
I'm trying to perform some basic analysis on Lotto results :)
I have a database that looks something like:
id|no|day|dd|mmm|yyyy|n1|n2|n3|n4|n5|n6|bb|jackpot|wins|machine|set
--------------------------------------------------------------------
1 |22|mon|22|aug|1999|01|05|11|29|38|39|04|2003202| 1 | Topaz | 3
2 |23|tue|24|aug|1999|01|06|16|21|25|39|03|2003202| 2 | Pearl | 1
That's just an example. So, n1 to n6 are standard balls in the lottery and bb stands for the bonus ball.
I want to write a PHP/SQL code that will display just one random sequence of numbers that have yet to come out. However, If the numbers 01, 04, 05, 11, 29, 38 and 39 have come out, I don't want the code to print out them numbers but just in a different order, as in theory them set of numbers are already winning numbers.
I just can't get my head around the logic of this. I'd appreciate any help.
Thanks in advance
Assuming that the balls are stored in ascending order in your database like the examples you've given, you could just generate a random sequence of 6 numbers, sort them and then generate 1 random bonus number. Once you've done that it would just be a matter of doing a simple SQL query into your database and seeing if it comes back with a result:
$nums=...//generate your 6 numbers plus bonus number here
sort($nums);
$mysqli=new mysqli('...','...','...','...');
$stmt=$mysqli->prepare("SELECT * FROM table
WHERE n1=? AND n2=? AND n3=? AND n4=? AND n5=? AND n6=? AND bb=?");
$stmt->bind_param('iiiiiii', $nums[0], $nums[1], $nums[2], $nums[3], $nums[4], $nums[5], $nums[6]);
$stmt->execute();
$stmt->store_result();
if($stmt->num_rows==0)
//your numbers have not been drawn before - return them
else
//otherwise loop round and try again
As long as both list of numbers (but not the bonus ball) are sorted you won't have any problems with a different ordering of an already drawn set of numbers.
This will become less efficient as your database of previous draws gets fuller, but I don't think you'll have to worry about that for a few decades. :-)
What about sorting each already drawn result (each row) in some order, ascending maybe, then sort the set of already drawn results (all rows)? Then you will have a easy to look up in list in which you can see what is left to be drawn.
Say for example you want a never drawn set before? You would just have to loop through the list until you spot a "hole", which would be a never before drawn set. If you would like to optimise further you could store at what index you last found a "hole" as well. Then you would never need to loop through the same part of the list twice, and you could even abandon "completed" parts of the list to save disk space, or if you would like the new number you come up with to seam random you could start at a random offset in the list.
To do this effectively you should make an extra column to store the pre-sorted set. For example if you have (5, 3, 6, 4, 1, 2) that column could contain 010203040506. Add in enough zeros so that the numbers occur on a fixed offset basis.