Displaying data from MySql a different way
Posted on
16th Feb 2014 07:03 pm by
admin
Hi all,
I'm pretty new to php and MySql and have hit a problem.
I am able to display data in a table using the following code:
<?php
$database="MYDATABASE";
mysql_connect ("localhost", "MYUSERNAME", "MYPASSWORD");
@mysql_select_db($database) or die( "Unable to select database");
$result = mysql_query( "SELECT field1, field2, field3 FROM staff WHERE `group` = 'group1' ORDER BY `role` " )
or die("SELECT Error: ".mysql_error());
$num_rows = mysql_num_rows($result);
print "There are $num_rows records.<P>";
print "<table width=200 border=1>n";
while ($get_info = mysql_fetch_row($result)){
print "<tr>n";
foreach ($get_info as $field)
print "t<td><font face=arial size=1/>$field</font></td>n";
print "</tr>n";
}
print "</table>n";
?>
However, I would like to display the results using the following format:
<div id="info"><!--this is a div contanier for info"-->
<h1> field1 </h1>
<img src="field2" class="floatLeft" /><p>field3</p>
</div><!--close info div-->
Obviously, if there was more than one row of results, it would repeat the above format for each row.
Any help would be greatly appreciated
Thanks
No comments posted yet
Your Answer:
Login to answer
308
43
Other forums
Logic question
im wondering what's the best method to do the above list:
it is for alliance @ MMORPG game
single values into sql field
i have a form which i want the user to able to select multiple answers. But i want the answers to be
shoping cart issues
i´ve wrote this and works when i add an item to, my cart, but when i want to add othrer item just
LinkedList help
Ok so I just learned quickly about lists, so I have a not too hard project I think, but am having a
Windows 7
Windows 7 default user account control worries experts. Corporate IT departments should be pleased w
Modal Popup Help
Hi guys, I have a modal popup with an iframe. How can i send data from a label or textbox to the ifr
Preserving user-entered linebreaks
Hi, I'm building a web 2.0 thingy from scratch and I wanna display text which users input. It's all
Remove letter from numeric textbox
I have a textbox that will search the employee database by entering in the employee ID and it will r
Echoing ASCII code
I have a php page that splits a string into chars and then echoes the ASCII code for each char. I'm
string to currency format
Hi guys...
Actually I chunk out some data from txtfile and one of the data contains amount va