php


PHP read text file and display formatted results


My goal is to use PHP to read data from a text file and display a page based on said data.
The text file would look something like this...
joe smith|ceo|chief executive officer|10|14|126
Jane Doe|cfo|chief financial officer|8|12|94
What I need to be able to do is read the text file, extract each of the values, separated by the "|" token, and format the output in a table-like display. When reading the text file, the first column (name) equates to a picture, located in a subfolder. Therefore, the output should look something like this...
Can anyone out there assist with this request?
Thanks in advance.
You need something like that:
I would save the Data in this example in a file called test.csv
But I think you get some problems with the first row. A Space in the src of the img-Tag....
I would replace the space from the Name with str_replace() in the PHP
and the space in the name of the Pictures with Underscrore "_"
<?php
echo '<table>';
$row = 1;
if (($handle = fopen("test.csv", "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, "|")) !==false) {
$num = count($data);
//print_r($data);
echo "<tr> ";
$row++;
for ($c=0; $c <= $num; $c++) {
if ($c==0){
echo '<td><img src="YOUR/SUBFOLDER/"'.$data[$c]
."/>".$data[$c].'</td>';
}else{
echo '<td>'.$data[$c] .'</td>';
}
}
echo "</tr> \n";
}
fclose($handle);
echo '</table>';
}
?>
Hope It Helps :-).
Sorry for my bad english

Related Links

bullet points not appearing for each hyperlink
Document Expires After Redirect If Form Did Not Validate
Generate rand hash by md5 and sha1
Passing a directory path as an argument in a user friendly URL
Date Query with Doctrine
Removing an item from a session associative arrays in php
fatal error in php
online offline and offline synchronization in php
why printing html code in email receive send by PHP?
How to put the data from mssql into a list box? PHP
Storing Multiple Values in PHP Variable
Selecting from the same table more than once in the same query
PHP Mysqli no errors, no querys
abort product add from sales_quote_add_item observer
Why is this prepared PHP PDO statement not working when the query() is?
session_register work but $_SESSION does not :/ [duplicate]

Categories

HOME
apache-nifi
paypal-ipn
message-queue
plpgsql
openlayers-3
semantic-web
web2py
liferay-7
iptables
azure-data-lake
hyperledger
supercollider
match
cqrs
lapack
jquery-select2-4
jquery-file-upload
async-await
cpu-usage
raml
bluemix-mobile-services
bsd
el
uri
running-object-table
ruby-daemons
npoi
sparkle
javax.persistence
materialize
fatfs
credit-card
infopath2010
vcenter
mongodb-3.4
series
ms-media-foundation
autoencoder
transform
formsauthenticationticket
ms-solver-foundation
aurelia-http-client
rdp
secure-coding
minikube
docker-ucp
qvtkwidget
return-type
gestures
htmlspecialchars
ptvs
apache-modules
dymola
ndk-build
livecycle
tsqlt
coovachilli
fdt
mnesia
ioctl
opencyc
flow-js
quercus
scala-swing
sablecc
mutators
hp-idol-ondemand
adhoc-polymorphism
encryption-symmetric
datagridcomboboxcolumn
adwords-apiv201402
xhprof
webmethod
nachos
wso2bam
principalcontext
strcmp
ctp
frontbase
hints
node.js-stream
red-system
multiscaleimage
story
wiktionary
memory-pool
mediacontroller
rtd
simile
jmenu
bll
webresponse
outlook-2007-addin
zend-test
spring-modules
source-code-protection
jquery-effects
rtti
accumulator

Resources

Encrypt Message