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
43
Other forums
Is there something wrong?
Hi all,
Just a quick question... can someone look at this code and see if something is wrong?
user administration
Dear @all,
what I have to do to set the user defaults for new users. At the moment I woul
Problem in back link
I have page where i have given javascript back link but when i click on it browser give a message
Parse multirow HTML table
Hello all,
I have a site I am working on. Its a sports site and I am trying to add stats to a DB
PHP and MySQL on intranet?
Is it possible to use both these on an intranet network?
Passing variables with pagination - iterating through unique id per link
Hi everyone,
I have seen a few topics like this one. Still cant find the specific thing, so I am
Simpler method of getting variables from mysql
Hi Guys,
I'm trying to streamline my CMS's code and as I was writing a new page it occured to
Redirecting Admin
In my members table, I have a field called "perm" and it's set to zero for all members. Ho
Help uploading .JPG
I have a problem with upload images when the ending is .JPG capitalized.. I really don't know what c
button.click += new eventhandler() not works in if(!ispostback)
i want to use button.clcik event in function VIewScrap() which is called in if(!ispostback) but itdo