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
MASS PM
Hello all, I'm trying to send mass private messages to users in my database but keep getting an erro
Using unserialize()
Hi there.
I have some data in my database that is serialized.
e.g.
a:2:{i:0
dynamic table with forms
I have a table that is populated with mysql data and in teh first column there is a raido button tha
why this query can delete duplicates ?
why this query can delete duplicates ? Anybody can give me the detailed explanation ?
Tha
Problem with php's rename function
So, i'm having a problem with the php rename function. Basically my script 'delete_user.php' attempt
Mysql error message
help me find out what this error message means:
"Duplicate entry '0' for key 'PRIMARY'&q
Option box to change variable
Hello, i need help by making a script!
I need to write a file with option box, so a dropdown
printing links
Hi every1
i am connecting to a table in sql and the looping through with a while ($ var = my
FlashVar function how to insert variables
Hi guys. Im new in this forum and also new in php programming. Can you help me about this code?
<
Hit counter updating once per IP - IP HIT COUNTER
I have a hit counter, for the amount of views on a tutorial.
It'll do the query and then do..