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:
Did you know?Explore Trending and Topic pages for more stories like this.

<?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 Like 43 Dislike
Previous forums Next forums
Other forums

Session login issue
I'm wondering how to fix a problem I'm having with a session-based login system

Say I go to h

tag inside php...
hi


Code: <?php
echo "<td width="$columnWidth%" align=&

Need help in log in and log out?
hi there all of u. i have recently created a site for someone. i have placed log in and log out and

I apologise! It's a newbie to PHP feedback form problem!
Hi,

I am a total newbie to PHP. I am also a unemployed and need to get a job. So after 100% r

Recording popularity by day, week.. all time?
Hey everyone, I'm creating a site designed around users uploading music. How can I implement a syste

Impact of movement type 412 E on MAP
Hi

Usage of movement type 412 E is causing huge change in MAP .

Is there any r

IF STATEMENT HELP
Hi
i have created a calendar from a table:

Code: Calendar: October 2009
<table w

Does design fit in FPGA ?
Hi all,

I've made a large HCC-Design. Because of the program-size the compile process with th

SAP FICO learning materials
Hi all,
I am new to this world of SAP FICO. I have taken training on SAP FICO, but was wonderin

Deleted Delivery but material wont return
We deleted a delivery but the material its still pending.

We made a reverse goods movemen

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash