Reply
Formating results back from mysql
Old 07-02-2004, 01:05 AM
lothop's Avatar
Extreme Talker

Posts: 226
Ok... shesh I'm a dumbass lol!

It had to be the last thing I would check...

The admins rank stored in the database is actually 3...
Yeah... I know...


Umm, also how would I display the results into a table. So it doesn't look so hideous

I tried to make a seperate php part for each table... but... the code is crappy and there is probly an easier way todo it.

Cheers for your help Kyrnt & Dark-Skys99.
Thanks,
Lothop
lothop is offline
Reply With Quote
View Public Profile
 
Old 07-02-2004, 06:51 AM
celticbrue's Avatar
Extreme Talker

Posts: 175
Location: Wiltshire, England
Hi,

Took me a while to get up to speed on this thread, but try this: -

Change this: -

HTML Code:
<td class="forTexts">Guild started on 25/6/04</td>
</tr>
</table></td>
</tr>
</table></td>
<td width="675" valign="top"> 
to this

HTML Code:
<td class="forTexts">Guild started on 25/6/04</td>
</tr>
</table></td>
</tr>
</table></td>
<td width="675" align="center" valign="top" style="padding:10px;">
Then change this: -

PHP Code:
/* SQL */ 
$sqlquery "SELECT email,username,level_id FROM users"
$result mysql_query($sqlquery); 
$number mysql_num_rows($result); 

/* Display Results */ 
if($number 1
print 
"<CENTER><P>There Were No Results for Your Search</CENTER>"
else 

while(
$data mysql_fetch_array($result)) 

$username $data['username']; 
$level_id $data['level_id']; 
print 
"<p><b>Username:</b> $username<br></p>"
if( 
$level_id ==) echo '<img src="1.gif">'
if( 
$level_id ==10 ) echo '<img src="2.gif">'

To this: -

PHP Code:
/* SQL */ 
$sqlquery "SELECT email,username,level_id FROM users"
$result mysql_query($sqlquery); 
$number mysql_num_rows($result); 

/* Display Results */ 
if($number 1
print 
"<CENTER><P>There Were No Results for Your Search</CENTER>"
else 

while(
$data mysql_fetch_array($result)) 

$username $data['username']; 
$level_id $data['level_id']; 
print (
"<table width=\"640\" cellpadding=\"3\" cellspacing=\"0\" border=\"1\" bordercolor=\"#000060\">\n<tr>\n<td>\n<p><b>Username:</b> $username</p></td>\n</tr>\n<tr>\n<td>"); 
if( 
$level_id ==) { print("<img src=\"1.gif\">");
} elseif ( 
$level_id ==) {
print(
"<img src=\"2.gif\">"); 
}
print(
"</td>\n</tr>\n</table>\n<br><br>\n");

This should work - if it doesn't let me know and I will try harder!!!

Ian
celticbrue is offline
Reply With Quote
View Public Profile
 
Old 07-03-2004, 08:38 PM
lothop's Avatar
Extreme Talker

Posts: 226
Yeah, its kinda a massive thread

I'm hoping that it can end soon

Umm, that code works alright and everything. It seems kinda messy ><

Umm, here is what the page looks like atm.
http://www.lothop.clanecko.net/testing/members.php

Hrmm, I would kinda like it to look like
http://www.lothop.clanecko.net/testing/wannabe.php

Thanks for your help
lothop
lothop is offline
Reply With Quote
View Public Profile
 
Old 07-03-2004, 09:39 PM
celticbrue's Avatar
Extreme Talker

Posts: 175
Location: Wiltshire, England
Hi lothop,

Thats cool - I think this will do it.

Change this: -

PHP Code:

/* SQL */ 
$sqlquery "SELECT email,username,level_id FROM users"
$result mysql_query($sqlquery); 
$number mysql_num_rows($result); 

/* Display Results */ 
if($number 1
print 
"<CENTER><P>There Were No Results for Your Search</CENTER>"
else 

while(
$data mysql_fetch_array($result)) 

$username $data['username']; 
$level_id $data['level_id']; 
print (
"<table width=\"640\" cellpadding=\"3\" cellspacing=\"0\" border=\"1\" bordercolor=\"#000060\">\n<tr>\n<td>\n<p><b>Username:</b> $username</p></td>\n</tr>\n<tr>\n<td>"); 
if( 
$level_id ==) { print("<img src=\"1.gif\">"); 
} elseif ( 
$level_id ==) { 
print(
"<img src=\"2.gif\">"); 

print(
"</td>\n</tr>\n</table>\n<br><br>\n"); 

To this : -

This assumes you have column headings of username, age, bot, country, gender, level_id in your database table

PHP Code:

/* SQL */ 
$sqlquery "SELECT username,age,bot,country,gender,level_id FROM users"
$result mysql_query($sqlquery); 
$number mysql_num_rows($result); 

/* Display Results */ 
if($number 1
print 
"<CENTER><P>There Were No Results for Your Search</CENTER>"
else 
{

//The next line starts the table and gives the column headings

print("<table width=\"640\" cellpadding=\"3\" cellspacing=\"0\" border=\"1\" bordercolor=\"#000060\">\n<tr>\n<td>Username</td><td>Age</td><td>Bot</td><td>Country</td><td>Gender</td><td>Rank</td>\n</tr>\n");

//The loop through the array then sorts the data and prints it appropriately
 
while($data mysql_fetch_array($result)) 


print (
"<tr>\n<td>\n<p>$data[username]</p></td>\n<td>\n<p>$data[age]</p></td>\n<td>\n<p>$data[bot]</p></td>\n<td>\n<p>$data[country]</p></td>\n<td>\n<p>$data[gender]</p></td>\n<td>"); 

//Checks the User Level ID and prints the correct image

if( $data[level_id] == 1) { print("<img src=\"1.gif\">"); 
} elseif ( 
$data[level_id] == 3) { 
print(
"<img src=\"2.gif\">"); 

print(
"</td>\n</tr>\n"); 


//Close the table

print("</table>\n"); 
You might want to add some formatting to the table, either by assigning a class to the TD tags and using CSS to dictate the font/colour/background OR just using good old html on them in the above code.

Hope this works, but its about 2-30 am and I am knackered, let me know if I've got it wrong.

Regards

Ian

Last edited by celticbrue : 07-03-2004 at 09:45 PM.
celticbrue is offline
Reply With Quote
View Public Profile
 
Old 07-05-2004, 07:09 AM
lothop's Avatar
Extreme Talker

Posts: 226
Thanks for your help man.
Got it all formatted the way I wanted

I would like to know how to sort the users by rank but I'll start a new thread since this one is so friggen huge

Thanks for your guys help.
Lothop
lothop is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Formating results back from mysql

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.13484 seconds with 12 queries