473,379 Members | 1,252 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

to insert data in a html table

Hello,

here is the code:

<?
$a=array(1,2,3,4,5,6,7,8,9,10);
$b=array(1,3,5,7,9);
$c=array(1,1,2,2,3,3);
$d=array_count_values($b);
$e=array_count_values($c);

foreach($a as $key)
echo '<table><tr><td>'.$key.'</table></tr></td>';

foreach($d as $key=>$value)
echo '<table><tr><td>'.$key.'<td>'.$value.'</table></tr></td>';

foreach($e as $key=>$value)
echo '<table><tr><td>'.$key.'<td>'.$value.'</table></tr></td>';
?>

the result will be :

1
2
3
4
5
6
7
8
9
10
1 1
3 1
5 1
7 1
9 1
1 2
2 2
3 2

how can I formulate a php code to insert all in the same html table, like
this :

1 1 1 1 2
2 3 1 2 2
3 5 1 3 2
4 7 1
5 9 1
6
7
8
9
10

Thank you.
Jul 17 '05 #1
2 2380
<a> wrote:
here is the code:

<?
$a=array(1,2,3,4,5,6,7,8,9,10);
$b=array(1,3,5,7,9);
$c=array(1,1,2,2,3,3);
$d=array_count_values($b);
$e=array_count_values($c);
<snip>
how can I formulate a php code to insert all in the same html table

?
You have to fill each <td>...</td> from different arrays with different
indexes. Tough!
<?php
$a = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
$b = array(1, 3, 5, 7, 9);
$c = array(1, 1, 2, 2, 3, 3);
$d = array_count_values($b);
$e = array_count_values($c);

reset($a); reset($d); reset($e);
$aempty = $dempty = $eempty = false;

echo "<table>\n";
while (!$aempty || !$dempty || !$eempty) {
$row = "";

if (list($akey, $aval) = each($a)) $row .= "<td>$aval</td>";
else { $row .= "\x01"; $aempty = true; }

if (list($dkey, $dval) = each($d)) $row .= "<td>$dkey</td><td>$dval</td>";
else { $row .= "\x01\x01"; $dempty = true; }

if (list($ekey, $eval) = each($e)) $row .= "<td>$ekey</td><td>$eval</td>";
else { $row .= "\x01\x01"; $eempty = true; }

if ($row != "\x01\x01\x01\x01\x01") {
echo "<tr>", str_replace("\x01", '<td>--</td>', $row), "</tr>\n";
}
}
echo "</table>\n";
?>

--
Mail to my "From:" address is readable by all at http://www.dodgeit.com/
== ** ## !! ------------------------------------------------ !! ## ** ==
TEXT-ONLY mail to the whole "Reply-To:" address ("My Name" <my@address>)
may bypass my spam filter. If it does, I may reply from another address!
Jul 17 '05 #2
Tank you for the answer !
Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: newbie_mw | last post by:
Hi, I need urgent help with a novice problem. I would appreciate any advice, suggestions... Thanks a lot in advance! Here it is: I created a sign-up sheet (reg.html) where people fill in their...
16
by: Philip Boonzaaier | last post by:
I want to be able to generate SQL statements that will go through a list of data, effectively row by row, enquire on the database if this exists in the selected table- If it exists, then the colums...
3
by: Hai Nguyen | last post by:
Hi all I was attempting to insert multiple row by using a loop into a database.A table has 2 primary keys and one regular field (PR) (PR) ID Project Ans 1 2 a 1 ...
20
by: Guadala Harry | last post by:
In an ASCX, I have a Literal control into which I inject a at runtime. litInjectedContent.Text = dataClass.GetHTMLSnippetFromDB(someID); This works great as long as the contains just...
7
by: David Bear | last post by:
I have a dictionary that contains a row of data intended for a data base. The dictionary keys are the field names. The values are the values to be inserted. I am looking for a good pythonic...
0
by: isaac2004 | last post by:
im trying to make a page that reads simple user information and posts them to a table. the user can edit, delete and add new records, through a form on the page.using SQLs modifications like...
1
by: reagen | last post by:
dear all, please help me that my script cannot insert data to ms acces. <%@ Page Language="vb" ContentType="text/html"%> <%@ Import NameSpace = "System.Data" %> <%@ Import NameSpace =...
8
by: SaltyBoat | last post by:
Needing to import and parse data from a large PDF file into an Access 2002 table: I start by converted the PDF file to a html file. Then I read this html text file, line by line, into a table...
2
by: =?Utf-8?B?UGhpbGlw?= | last post by:
I am attempting to insert a simple record with LinqDataSource from a ListView, however I always get a message saying "....LinqDataSource 'dataSource' has no values to insert. Check that the...
2
by: wizardry | last post by:
hello - i'm trying to insert a blob into my table, it will insert but the string that i insert when i query the inserted data returns null with 0 bytes in the column. I have other tables set...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.