I have 5 pictures stored in a folder and their links stored on the database. I want to put them in a table of three columns on each row.
<body>
<center>
<table border='1'>
<?php
$host="";
$username="";
$password="";
$db_name="fruits_db";
$tbl_name="fruits_tbl";
$connection=mysqli_connect("$host","$username","$password","$db_name");
if (mysqli_connect_errno())
{
echo "The application has failed to connect to the mysql database server: " .mysqli_connect_error();
}
$result = mysqli_query($connection, "SELECT * FROM fruits_tbl")or die("Error: " . mysqli_error($connection));
$num_rows=mysqli_num_rows($result);
$rows = $num_rows/3;
for($i=1; $i<=$rows ; $i++)
{
echo "<tr>";
for($j=1; $j<=3; $j++)
{
while($row = mysqli_fetch_array($result))
{
echo
(
"<td width='180px' height='200px'>"
."<div class = 'fruit_image'>"
."<img src='"
.$row['fruit_image']
."'/>"
."</div>"
."<div class = 'fruit_title'>"
.$row['fruit_name']
."</div>"
."</td>"
);
}
}
echo "</tr>";
}
mysqli_close($connection);
?>
</table>
</center>
</body>
</html>
The above code I created, contains two FOR loops. The script should count the number of rows in the table, and then divide by 3(the number of columns on each row in the HTML table). I wonder where I'm going wrong wit this code.iinn hhttmmll uussiinngg pphhpp
ii hhaavvee 55 ppiiccttuurreess ssttoorreedd iinn aa ffoollddeerr aanndd tthheeiirr lliinnkkss ssttoorreedd oonn tthhee ddaattaabbaassee.. ii wwaanntt ttoo ppuutt tthheemm iinn aa ttaabbllee ooff tthhrreeee ccoolluummnnss oonn eeaacchh rrooww..
,,bbooddyy..
,,cceenntteerr..
,,ttaabbllee bboorrddeerr==''11''..
,,//pphhpp
44hhoosstt=='''';;
44uusseerrnnaammee=='''';;
44ppaasssswwoorrdd=='''';;
44ddbb--nnaammee==''ffrruuiittss--ddbb'';;
44ttbbll--nnaammee==''ffrruuiittss--ttbbll'';;
44ccoonnnneeccttiioonn==mmyyssqqllii--ccoonnnneecctt99''44hhoosstt'',,''44uusseerrnnaammee'',,''44ppaasssswwoorrdd'',,''44ddbb--nnaammee''00;;
iiff 99mmyyssqqllii--ccoonnnneecctt--eerrrrnnoo990000
[[
eecchhoo ''tthhee aapppplliiccaattiioonn hhaass ffaaiilleedd ttoo ccoonnnneecctt ttoo tthhee mmyyssqqll ddaattaabbaassee sseerrvveerr;; '' ..mmyyssqqllii--ccoonnnneecctt--eerrrroorr9900;;
]]
44rreessuulltt == mmyyssqqllii--qquueerryy9944ccoonnnneeccttiioonn,, ''sseelleecctt 88 ffrroomm ffrruuiittss--ttbbll''00oorr ddiiee99''eerrrroorr;; '' .. mmyyssqqllii--eerrrroorr9944ccoonnnneeccttiioonn0000;;
44nnuumm--rroowwss==mmyyssqqllii--nnuumm--rroowwss9944rreessuulltt00;;
44rroowwss == 44nnuumm--rroowwss//33;;
ffoorr9944ii==11;; 44ii,,==44rroowwss ;; 44ii====00
[[
eecchhoo '',,ttrr..'';;
ffoorr9944jj==11;; 44jj,,==33;; 44jj====00
[[
wwhhiillee9944rrooww == mmyyssqqllii--ffeettcchh--aarrrraayy9944rreessuulltt0000
[[
eecchhoo
99
'',,ttdd wwiiddtthh==''118800ppxx'' hheeiigghhtt==''220000ppxx''..''
..'',,ddiivv ccllaassss == ''ffrruuiitt--iimmaaggee''..''
..'',,iimmgg ssrrcc==''''
..44rrooww[[''ffrruuiitt--iimmaaggee'']]
..''''//..''
..'',,//ddiivv..''
..'',,ddiivv ccllaassss == ''ffrruuiitt--ttiittllee''..''
..44rrooww[[''ffrruuiitt--nnaammee'']]
..'',,//ddiivv..''
..'',,//ttdd..''
00;;
]]
]]
eecchhoo '',,//ttrr..'';;
]]
Firestorm Viewer crashes on startup in ubuntu. Help me?
I'm New on Linux ( Ubuntu ), and I wanted to go on Second Life with Firestorm Viewer, I think i correctly install it but when I start it. It just only crashes.
mmyyssqqllii--cclloossee9944ccoonnnneeccttiioonn00;;
//..
,,//ttaabbllee..
,,//cceenntteerr..
,,//bbooddyy..
,,//hhttmmll..
tthhee aabboovvee ccooddee ii ccrreeaatteedd,, ccoonnttaaiinnss ttwwoo ffoorr llooooppss.. tthhee ssccrriipptt sshhoouulldd ccoouunntt tthhee nnuummbbeerr ooff rroowwss iinn tthhee ttaabbllee,, aanndd tthheenn ddiivviiddee bbyy 3399tthhee nnuummbbeerr ooff ccoolluummnnss oonn eeaacchh rrooww iinn tthhee hhttmmll ttaabbllee00.. ii wwoonnddeerr wwhheerree ii''mm ggooiinngg wwrroonngg wwiitt tthhiiss ccooddee..
No comments:
Post a Comment