php


how to create html tables defining a columns at a time


I have two for loops to draw a HTML table and I want to draw the columns from the first for loop and add the rows from the second for loop. But the tables cant draw in the following way.
for($i=0;$i<$diffc;$i++){
?>
<td>
<?php
for($j=0;$j<2;$j++){
?>
<tr>MODEL</tr>
<tr><?php echo $modelNo; ?></tr>
<tr>MODELw</tr>
<tr><?php echo $model; ?></tr>
<?php
}
?>
</td>
<?php
}
Any idea how I should do this?
You are right, tables are drawn row first, then by column (can't be the other way around).
So, you might want to (assuming you're using PHP):
Create your 2-dimensional array representing the table cell values (in PHP).
Draw your table by iterating through each row, then by column.
You do end up having to perform extra loops with this method.
First of all you have to undrestand how tables work in html then you can do it easily in php.
So you are using two loops to draw the table. In the first loop you want to draw the columns and in the second you want to draw the rows. So here is how to do it.
here is structure of html table.
<table>
<tr>
<td>1 Column</td>
</tr>
</table>
In the first loop draw the following html code
<table>
<tr>
<td>Column 1</td><td>Column 2</td><td>Column 3</td>
</tr>
end of first loop.
then in the second loop draw the following html
<tr>
<td>row 1</td><td>row 2</td><td>row 3</td>
</tr>
<tr>
<td>row 1</td><td>row 2</td><td>row 3</td>
</tr>
<tr>
<td>row 1</td><td>row 2</td><td>row 3</td>
</tr>
</table>
If you dont know how to do it in php then let me know.

Related Links

Prestashop console error “TypeError: jsonData is null”
Open many PHP header in loop
Understanding Date function Parameters in PHP
i am getting an error when i tried to set webhook for telegram
Why Won't my PHP Form Code work Correctly?
Getting unknown property: yii\console\Application::session while run ./yii
Can't echo $_GET
PHP Magento 2 OAuth Issue
PHP variable overriding preceding variable
Check if something is before character php [closed]
Sementical error The annotation "#JMS\Serializer\Annotation\SerializedName in property in … does not exist, or could not be auto-loaded
How to get the “reply to comment form” or “respond to” in worpress
Create single line SQL entry from multi line query and post it into a new table
Check if an image URL is transparent with PHP
Show partial edit button in own Wordpress theme
XML connection issue

Categories

HOME
jboss
visual-studio
bokeh
schema.org
couchdb
devexpress
activemq
histogram
web2py
google-webmaster-tools
liferay-7
lvm
dependencies
qooxdoo
google-sheets-query
biztalk-2010
iptables
turbojpeg
bittorrent
firebase-database
responsive-design
mailgun
fresco
hidden
node-webkit
bsd
multi-upload
router
plyr
webviewclient
ccavenue
code-climate
iwebbrowser2
substance
guice
autodesk-model-derivative
cucumber-junit
quickcheck
autoencoder
landscape
runtimeexception
mv
sspi
extbase
assert
plane
viewcontroller
openstack-glance
google-identity-toolkit
thread-exceptions
libharu
visual-studio-monaco
always-on-top
ftp-client
cdo.message
meld
codecharge
frame-grab
android-async-http
xcopy
textblock
polymerfire
teamviewer
gravatar
wikimedia-commons
phpquery
featuretoggle
libz
mobilefirst-server
componentart
console.log
quercus
fuseesb
ssmtp
tkx
microsoft-expression-web
dmake
tabris
lmax
webautomation
commenting
air-native-extension
hotswap
discovery
disjoint-union
postgres-xc
xs
sly-scroller
getproperty
popup-blocker
arrow
first-class
pcspim
java.lang.class
fitch-proofs
asio
firefly-mv
nsrangeexception
asp.net-mvc-views
bass
.net-services
jquery-effects
xap
levels

Resources

Encrypt Message