Convert a parse ini to array / objects - php

I'm using a program I made to scrape a file for text and parse the information into a ini file. I asked a question here earlier asking about parse_ini_file and why I could not use the indexes and someone gave me a way to loop through using this.
$ini_array = parse_ini_file("myfile.ini", true
foreach($ini_array as $key=>$value)
I then echo out the result echo ($value['Username']) . " "; and store it into the table. I have the table functioning link here, http://liveviewtest.byethost7.com/index.php but the plugin I'm using is not functioning as intended. The sorting does not work, and I'm wondering is it because the data type? http://www.datatables.net/manual/data tells you that the accepted data types are arrays, objects, and instances. My question is what would be the best way for me to convert this into one of these data types? I'm new to php / html so sorry if this is basic.
Php File http://pastebin.com/VRUHLdMQ
Ini File http://pastebin.com/yZsg16qA

Your table is being generated so PHP & Ini file are fine but HTML code you are generating is incorrect so either DataTable plugin or jQuery DOM parser is confused.
Please fix it and it should work fine.
Put jquery+datatables js/css into <head> section.
You use multiple <tbody> and you put </tr> after </tbody>
So basically you shoud put echo "</tbody>"; outside loop so
echo "<tbody>"; // <<< HERE
foreach ($ini_array as $key => $value) {
echo "<tr>";
for ($i = 0; $i < 12; $i++) {
echo "<td>";
echo ($value[$getstats[$i]]);
echo "</td>";
}
echo "</tr>";
}
echo "</tbody>"; // <<< HERE
I'm wondering is it because the data type? http://www.datatables.net/manual/data tells you that the accepted data types are arrays, objects, and instances.
No, your code its fine as manual says Data can be read from DOM. You need arrays/objects/instances if you create table straight from javascript.
See below:
DOM
When DataTables starts up, it will automatically check the table it is operating on for data that already exists inside it and use it for the table (note that it will throw this data away if you pass in data using data or ajax to get new data!). This is the simplest method of using DataTables - working with a regular HTML table.
Note that when using a DOM sourced table, DataTables will use arrays as the data source (see above) by default, although you could use the columns.data option to have it construct objects for the row data instead.
http://www.datatables.net/manual/data#DOM

Your table structure was not correct :
<html>
<head>
<!-- DataTables CSS -->
<link rel="stylesheet" type="text/css" href="http://liveviewtest.byethost7.com/DataTables-1.10.9/media/css/jquery.dataTables.css">
<!-- jQuery -->
<script type="text/javascript" src="http://liveviewtest.byethost7.com/DataTables-1.10.9/media/js/jquery.js"></script>
<!-- DataTables -->
<script type="text/javascript" src="http://liveviewtest.byethost7.com/DataTables-1.10.9/media/js/jquery.dataTables.js"></script>
<!--<link rel="stylesheet" type="text/css" href="http://liveviewtest.byethost7.com/style.css">-->
</head>
<body>
<script type="text/javascript">
$(document).ready(function () {
$('#mytable').DataTable();
});
</script>
<table id="mytable" border ="1" style="width:100%">
<thead>
<tr>
<th>Name</th>
<th>Kills</th>
<th>Death Total</th>
<th>Suicides</th>
<th>Bears</th>
<th>Wolves</th>
<th>Helicopter</th>
<th>Falling</th>
<th>Cold</th>
<th>Explosions</th>
<th>Barricade</th>
<th>Player Deaths</th>
</thead>
<tbody>
<tr>
<td>hpnotiq</td>
<td>0</td>
<td>1</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td><td>1</td><td>0</td><td>0</td></tr><tr><td>TacticalNuke735</td><td>1</td><td>12</td><td>12</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td></tr><tr><td>.buckisM</td><td>2</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td></tr><tr><td>Mrs Phluffy</td><td>0</td><td>4</td><td>1</td><td>1</td><td>0</td><td>1</td><td>1</td><td>0</td><td>0</td><td>0</td><td>0</td></tr><tr><td>My buddy's goin'a jail</td><td>6</td><td>134</td><td>126</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>8</td></tr><tr><td>marble</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td></tr><tr><td>Sir Joe</td><td>0</td><td>5</td><td>2</td><td>0</td><td>0</td><td>2</td><td>0</td><td>0</td><td>0</td><td>0</td><td>1</td></tr><tr><td>StryX</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td></tr><tr><td>Haroth</td><td>6</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td></tr><tr><td>Mr Sephy</td><td>2</td><td>6</td><td>4</td><td>0</td><td>0</td><td>1</td><td>0</td><td>1</td><td>0</td><td>0</td><td>0</td></tr><tr><td>Solblade531</td><td>2</td><td>4</td><td>2</td><td>0</td><td>0</td><td>1</td><td>0</td><td>0</td><td>0</td><td>0</td><td>1</td></tr><tr><td>Vavbro</td><td>3</td><td>14</td><td>8</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>6</td></tr><tr><td>Heisenberg</td><td>0</td><td>1</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>1</td></tr><tr><td>アッパーおっぱい</td><td>3</td><td>1</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>1</td><td>0</td><td>0</td></tr><tr><td>Tallsockboy</td><td>0</td><td>1</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>1</td></tr><tr><td>CHAPYSIX</td><td>1</td><td>2</td><td>1</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>1</td></tr><tr><td>Bik</td><td>0</td><td>1</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>1</td></tr><tr><td>Totes MiGoats</td><td>0</td><td>8</td><td>5</td><td>0</td><td>0</td><td>1</td><td>0</td><td>0</td><td>0</td><td>0</td><td>2</td></tr><tr><td>Blunted Out'cha Mind</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td></tr><tr><td>Jubby</td><td>0</td><td>1</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>1</td></tr><tr><td>That0neGuy</td><td>0</td><td>1</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>1</td></tr><tr><td>Nuclear</td><td>0</td><td>1</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>1</td></tr><tr><td>michaelswansey</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td></tr><tr><td>kapiowai</td><td>0</td><td>1</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>1</td></tr><tr><td>Kami</td><td>0</td><td>1</td><td>1</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td></tr><tr><td>Pika</td><td>0</td><td>1</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>1</td></tr><tr><td>WC Visuals</td><td>0</td><td>2</td><td>2</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td></tr><tr><td>STUDNASTY</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td></tr><tr><td>masternubb</td><td>0</td><td>2</td><td>0</td><td>0</td><td>1</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>1</td></tr><tr><td>Bignubbb</td><td>2</td><td>5</td><td>4</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>1</td></tr><tr><td>BAAABBYNUBB</td><td>0</td><td>1</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>1</td></tr><tr><td>Squirt</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td></tr><tr><td>Fluffy</td><td>0</td><td>1</td><td>1</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td></tr><tr><td>| Albatross</td><td>0</td><td>1</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>1</td></tr><tr><td>inmate #42069 weston gayboy</td><td>10</td><td>9</td><td>5</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>1</td><td>0</td><td>3</td></tr><tr><td>isaiahyo</td><td>0</td><td>8</td><td>3</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>2</td><td>3</td></tr><tr><td>Vortex</td><td>1</td><td>5</td><td>3</td><td>0</td><td>0</td><td>0</td><td>0</td><td>1</td><td>0</td><td>0</td><td>1</td></tr><tr><td>General Pro</td><td>0</td><td>1</td><td>1</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td></tr><tr><td>Ecchi Sketchy</td><td>0</td><td>1</td><td>1</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td></tr><tr><td>a e s t h e t i c</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td></tr><tr><td>TheS1mpleGuy2Know</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td></tr><tr><td>♥JaPierDoLe™</td><td>0</td><td>1</td><td>1</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td></tr><tr><td>JaidenV</td><td>1</td><td>2</td><td>1</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>1</td></tr><tr><td>FaceEatingTumor</td><td>0</td><td>1</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>1</td></tr><tr><td>Jfrisk</td><td>1</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td></tr><tr><td>Kilgore</td><td>0</td><td>1</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>1</td></tr><tr><td>chilmonik</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td></tr><tr><td>chrishawsome</td><td>0</td><td>1</td><td>0</td><td>0</td><td>1</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td></tr><tr><td>s4MPL3</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td></tr><tr><td>Dan Gleasak</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr></tbody>
</table>
</body>
</html>

Related

How is this PHP while loop code creating new table rows?

You can see that I have a 3 element array. I am using a while loop to then print out all 3 values into a table, one row for each of the three values, but I do not understand how three rows are being printed out when I only have one row hard coded using html code. The PHP while loop does not echo the tr and td tags for each row because those row and detail tags are outside the PHP code. The code works -- it prints out one additional new table row for each value of "mary","donna","shirley", but I do not understand how. I could see it working if the tr and td tags were output by a PHP echo statement inside the while loop, but that is not the case here.
<html>
<body>
<table cellspacing ="2" cellpadding ="2" align ="center" border="8">
<?php
$ar1=["mary","donna","shirley"];
$len=count($ar1);
$ct=0;
?>
<?php while ( $ct<$len) { ?>
<tr>
<td>
<?php echo $ar1[$ct];
$ct++;
?>
</td>
</tr>
<?php } //end while loop?>
</table>
</body>
</html>
I believe the answer lies in the fact that HTML is an interpreted language not a compiled language.
So in this case your php while loop is setting the browser back to the spot just before your first tr tag so it goes through and interprets those tags again, and as it does this it puts them to the page again. Doing your while loop like this is a cheap way to do echos essentially.
I'm not a PHP master by any means, but from my understanding of how HTML is read and how PHP works this is my answer.
Your <tr> tag is inside the while loop. If you want just one row, try this-
<html>
<body>
<table cellspacing ="2" cellpadding ="2" align ="center" border="8">
<?php
$ar1=["mary","donna","shirley"];
$len=count($ar1);
$ct=0;
?>
<tr>
<?php while ( $ct<$len) { ?>
<td>
<?php echo $ar1[$ct];
$ct++;
?>
</td>
<?php } //end while loop?>
</tr>
</table>
</body>
</html>
This piece of code:
<?php while ( $ct<$len) { ?>
<tr>
<td>
<?php echo $ar1[$ct];
$ct++;
?>
</td>
</tr>
<?php } //end while loop?>
is the same as
<?php while ( $ct<$len) {
echo "<tr>
<td>";
echo $ar1[$ct];
$ct++;
echo "</td>
</tr>";
} //end while loop?>
if you analyze code more deeply..u will understand it yourself..you said "The php while loop does not echo the tr and td tags for each row because those row and detail tags are outside the php code"
but it does ..the html code is not the part of php code it coded outside php scope...and whenever your while loop executes it again reads the tr and tg tag and insert row and hence u get three rows printed ...
It's an easy case of PHP basic capabilities.
See http://php.net/manual/en/language.basic-syntax.phpmode.php
Everything outside of a pair of opening and closing tags is ignored by the PHP parser which allows PHP files to have mixed content.
PHP parser, don't need to know what is inside the While Loop, it just repeat to the output.
In a php file, by escaping the php code (by way of ?> you basicly say to the script, now comes something non php, you provide Html tags which are then interpreted by the browser as html code. But because you're still in the loop (you haven't ended it by adding an closing tag } you repeat the exit from the code, presenting html, and then entering the code again.
Some coders prefer to just exit php code and to show some html code with a few php tags here and there when there's a large amount of html being displayed. It's a lot less typing than continually using echo statements.

Return Seperate PHP Script Within HTML

I have a "print.php" script that basically fetches data from MySQL and creates a tiny pretty HTML table.
echo "
<table cellpadding=\"2\" cellspacing=\"2\" border=\"0\" width=\"10%\">
<tr bgcolor=\"#666666\">
<td colspan=\"2\" align=\"center\"><b><font color=\"#FFFFFF\">" . $table[0] . "</font></td>
</tr>
<tr>
<td>Name</td>
<td>Score</td>
</tr>";
echo "<tr";
if ($i % 2 == 0)
echo " bgcolor=\"#CCCCCC\"";
echo ">
<td>" . $col['player'] . "</td>
<td>" . $col['score'] . "</td>
</tr>";
I want this table to appear in my index.html, But its in a separate php script.
I want to keep the php script separate from the HTML because the script is not only a tad large, but it has my SQL information in it to which I don't want in the plain HTML.
Is there a way to fetch this echo in my php script from my html page?
Option 1:
Use an iframe. Works even if JavaScript is turned off.
<iframe src="print.php"></iframe>
Option 2: Use AJAX (with jQuery).
Download jQuery here.
Include it in your index.html, preferably in your head tag.
<script type="text/javascript" src="path/to/jquery.js"></script>
Add this code where you want print.php to be included.
<div id="container"></div>
<script type="text/javascript">
$(function(){
$("#container").load("print.php");
});
</script>
Option 3: Go the PHP route. May break other code since you need to rename the index file.
Rename your index.html to index.php and use this code:
<?php include("print.php"); ?>
You can use AJAX Javascript to do that.
Documentation And Examples
You can make a AJAX call to the print.php from the your current page and fetch the data and show them.
$.ajax({
url: "print.php"
}).done(function( html ) {
$("#results").append(html); //results is the div id
});
You will have to get the basic jQuery knowledge for this.
Else you can use .load method which is also a AJAX method.
<div id="results"></div>
$("#results").load("print.php");

Convert HTML output into a plain text using php

I'm trying to convert my sample HTML output into a plain text but I don't know how. I use file_get_contents but the page which I'm trying to convert returns most like the same.
$raw = "http://localhost/guestbook/profiles.php";
$file_converted = file_get_contents($raw);
echo $file_converted;
profiles.php
<html>
<head>
<title>Profiles - GuestBook</title>
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
<!-- Some Divs -->
<div id="profile-wrapper">
<h2>Profile</h2>
<table>
<tr>
<td>Name:</td><td> John Dela Cruz</td>
</tr>
<tr>
<td>Age:</td><td>15</td>
</tr>
<tr>
<td>Location:</td><td> SomewhereIn, Asia</td>
</tr>
</table>
</div>
</body>
</html>
Basically, I trying to echo out something like this (plain text, no styles)
Profile
Name: John Dela Cruz
Age: 15
Location: SomewhereIn, Asia
but i don't know how. :-( . Please help me guys , thank you in advance.
EDIT: Since i am only after of the content of the page, no matter if it's styled or just a plain text , is there a way to select only (see code below) using file_get_contents() ?
<h2>Profile</h2>
<table>
<tr>
<td>Name:</td><td> John Dela Cruz</td>
</tr>
<tr>
<td>Age:</td><td>15</td>
</tr>
<tr>
<td>Location:</td><td> SomewhereIn, Asia</td>
</tr>
</table>
Use php strip_tags
If strip_tags is not working for then maybe you can use regex to extract the info you want.
Try using PHP preg_match with /(<td>.*?<\/td>)/ as the pattern
Have a look at simplexml_load_file():
http://www.php.net/manual/en/function.simplexml-load-file.php
It will allow you to load the HTML data into an object (SimpleXMLElement) and traverse that object like a tree.
try to use PHP function strip_tags
try this one,
<?php
$data = file_get_contents("your_file");
preg_match_all('|<div[^>]*?>(.*?)</div>|si',$data, $result);
print_r($result[0][0]);
?>
I have try this one, and it seems work for me, for you too i hope
You can use the strip_tags php function for this. Browse through the comments in the php manual page of the strip_tags function to see how you can use this in a good way.

jquery datatable and cakePHP

i am trying to implement jquery datatable, in my cakePHP based website, but it just wont load. this website is already half developed, and from the way i see it, the js' is loaded through a file called _head.inc.ctp located inside the views/layouts folder, i have added the datatables library inside the libs folder which is webroot/js/libs and load it inside the _head.inc.ctp file.
suppose i have this:
my controller:
var $helpers = array(
'Form',
'Html',
'Javascript'
);
//my method
function dataTable_example($id=null){
$details = $this->Detail->find("all");
$this->set('details', $details );
}
my view:
<div>
<?php echo $javascript->link('libs/jquery.dataTables.js'); ?>
<script>
$(document).ready(function(){
$('#js-datatable').dataTable();
});
</script>
<h2><?php echo __l('Tickets');?></h2>
<div>
<table id="js-datatable">
<tr>
<th>some heading 1</th>
<th>some heading 1</th>
<th>some heading 1</th>
</tr>
<?php
if (!empty($details)){
foreach ($details as $detail):
?>
<tr>
<td><?php echo $detail['Detail']['id'];?></td>
<td><?php echo $detail['Detail']['created'];?></td>
<td><?php echo $detail['Detail']['ticket_detail'];?></td>
</tr>
<?php
endforeach;
}else{
?>
<tr>
<td>No Data Found</td>
</tr>
<?php }?>
</table>
</div>
</div>
i even hard coded it using the usual call, and checked it using firebug to see if the script is loaded or not, and according to firebug, it is loaded, so i cant see whats making the script fail my table.
did i missed some steps ? please help
thanks
You don't have thead and tbody elements as required by the datatables script
You should use the find function in your controller and pass the array to the view and in the view write it.. don't just leave the table empty

make array object in for loop with horizontal view

<?php
$xml = simplexml_load_file('http://www.google.com/ig/api?weather=London');
$information = $xml->xpath("/xml_api_reply/weather/forecast_information");
$current = $xml->xpath("/xml_api_reply/weather/current_conditions");
$forecast_list = $xml->xpath("/xml_api_reply/weather/forecast_conditions");
?>
<html>
<head>
<title>Google Weather API</title>
</head>
<body>
<h1><?php print $information[0]->city['data']; ?></h1>
<h2>Today's weather</h2>
<div class="weather">
<img src="<?php echo 'http://www.google.com' . $current[0]->icon['data']?>" alt="weather"?>
<span class="condition">
<?php echo round(conver_f_c($current[0]->temp_f['data'])); ?>° C,
<?php echo $current[0]->condition['data'] ?>
</span>
</div>
<h2>Forecast</h2>
<?php foreach ($forecast_list as $forecast) : ?>
<div class="weather">
<img src="<?php echo 'http://www.google.com' . $forecast->icon['data']?>" alt="weather"?>
<div><?php echo $forecast->day_of_week['data']; ?></div>
<span class="condition">
<?php echo round(conver_f_c($forecast->low['data'])); ?>° C - <?php echo round(conver_f_c($forecast->high['data'])); ?>° C,
<?php echo $forecast->condition['data'] ?>
</span>
</div>
<?php endforeach ?>
</body>
</html>
<?php
function conver_f_c($F){
return $C = ($F − 32) * 5/9;
}
I want Out somthing like this manner of the horizontal ,
Even i tried UL LI WITH display inline but it goes failed,
Tell me some good suggestion for my probme,
I want exactly like horizontal, expecting exactly like screen shot ,
Tell me How to render using php
Thanks
alt text http://img163.imageshack.us/img163/7518/weatherhori.jpg
Above snippet present display out verticly , i want o change that verticle to horizonatal ,
somthing like this screen shot
<table>...</table>
Update
From your latest comment so far:
i know how to fetch array and display
it, but i dont know to fetch and
display in the verticl manner that is
the stuck up
I feel this is going to be a stupid answer but it appears to be what you don't understand...
The web is based in a markup language called HTML. This language has tags (delimited by angle-brackets) that allow you to define the structure of a document. On top of this, you have another language called CSS. This other lang allow you to define how HTML is going to be displayed on screen.
You may argue that you already have a web page and you've written it with the PHP language instead of the two other langs I've mentioned. That's not enterely true: you code in PHP, sure, but you use PHP to generate HTML. And it's HTML what finally reaches the browser (Firefox, Explorer...). PHP is executed in the web server, not in the browser. The browser can only see whatever HTML you've generated.
To sum up: you have to forget about PHP, Google and the whole weather thingy. You first need to write a static HTML document and style it with CSS. Once you've done with it, you can finally replace the parts of the information that are dynamic with values taken from your PHP variables.
And since you seem to need a table to display tabular data, the appropriate HTML tag is <table>:
<table>
<tr>
<th>Web</th>
<th>Thu</th>
<th>Fri</th>
<th>Sat</th>
</tr>
<tr>
<td><img src="/path/to/pics/cloudy.png" width="25" height="25" alt="Cloudy"></td>
<td><img src="/path/to/pics/sunny.png" width="25" height="25" alt="Sunny"></td>
<td><img src="/path/to/pics/rainy.png" width="25" height="25" alt="Rainy"></td>
<td><img src="/path/to/pics/cloudy.png" width="25" height="25" alt="Cloudy"></td>
</tr>
<tr>
<td>26ºC</td>
<td>26ºC</td>
<td>22ºC</td>
<td>25ºC</td>
</tr>
<table>
I suggest you find some tutorials about basic HTML and CSS. They'll be of invaluable help.
This is what's done by Google :
http://jsfiddle.net/bW8NA/1

Categories