xyn Posted July 15, 2006 Share Posted July 15, 2006 Hi,This is very minor but it's quite irritating as it wont work. I'm trying to choose certain rows from my database as it is quicker to load pages and gather information, however my problem is i get blank spaces.code:[code=php:0]<?$result = mysql_query("SELECT id,user,rank,rep FROM accounts ORDER BY 'id' ASC"); while($data = mysql_fetch_row($result)){ echo '<tr> <td width="25%" align="center" height="20"> <font face="Verdana" size="1" color="#54A800">'.$data["user"].'</font></td> <td width="25%" align="center" height="20"> <font face="Verdana" size="1" color="#54A800">'.$data["rank"].'</font></td> <td width="25%" align="center" height="20"> <font face="Verdana" size="1" color="#54A800">'.$data["rep"].'</font></td> <td width="25%" align="center" height="20"> <font size="1" face="Verdana" color="#54A800">[ <a href="contact.php?id='.$data["id"].'">PM</a> ]</font></td> </tr>'; }?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/14687-sql-help/ Share on other sites More sharing options...
koolaidman52 Posted July 15, 2006 Share Posted July 15, 2006 methinks $data["rep"] needs to be {$data["rep"]}also are you afraid of escaping quotation marks or something? you could do that whole thing without periods Quote Link to comment https://forums.phpfreaks.com/topic/14687-sql-help/#findComment-58578 Share on other sites More sharing options...
xyn Posted July 15, 2006 Author Share Posted July 15, 2006 Nope i got errors Quote Link to comment https://forums.phpfreaks.com/topic/14687-sql-help/#findComment-58579 Share on other sites More sharing options...
koolaidman52 Posted July 15, 2006 Share Posted July 15, 2006 what errors?are you logged onto the DB? (using mysql_connect and mysql_select_db) Quote Link to comment https://forums.phpfreaks.com/topic/14687-sql-help/#findComment-58581 Share on other sites More sharing options...
pixy Posted July 15, 2006 Share Posted July 15, 2006 Try this:[code]<?php$result = mysql_query("SELECT id, user, rank, rep FROM accounts ORDER BY id ASC");while ($data = mysql_fetch_row($result, MYSQL_NUM)) { echo '<tr> <td width="25%" align="center" height="20"> <font face="Verdana" size="1" color="#54A800">'.$data[1].'</font></td> <td width="25%" align="center" height="20"> <font face="Verdana" size="1" color="#54A800">'.$data[2].'</font></td> <td width="25%" align="center" height="20"> <font face="Verdana" size="1" color="#54A800">'.$data[3].'</font></td> <td width="25%" align="center" height="20"> <font size="1" face="Verdana" color="#54A800">[ <a href="contact.php?id='.$data[0].'">PM</a> ]</font></td> </tr>';}?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/14687-sql-help/#findComment-58582 Share on other sites More sharing options...
pixy Posted July 15, 2006 Share Posted July 15, 2006 Try miiiiiiiiiine. :)Dude, you don't use { } when dealing with single quotes. Quote Link to comment https://forums.phpfreaks.com/topic/14687-sql-help/#findComment-58583 Share on other sites More sharing options...
xyn Posted July 15, 2006 Author Share Posted July 15, 2006 I have tried yours :Pi got this:Warning: Wrong parameter count for mysql_fetch_row() in /home/zroxxco/public_html/Zone/Members.php on line 52 Quote Link to comment https://forums.phpfreaks.com/topic/14687-sql-help/#findComment-58584 Share on other sites More sharing options...
pixy Posted July 15, 2006 Share Posted July 15, 2006 Oops, I'm stupid. I used mysql_fetch_row() instead of mysql_fetch_array(). I never use the first function, so I have no idea how it came into my head...oh, that's because it's what you were using. That was probably your problem. Try this:[code]<?php$result = mysql_query("SELECT id, user, rank, rep FROM accounts ORDER BY id ASC");while ($data = mysql_fetch_array($result, MYSQL_NUM)) { echo '<tr> <td width="25%" align="center" height="20"> <font face="Verdana" size="1" color="#54A800">'.$data[1].'</font></td> <td width="25%" align="center" height="20"> <font face="Verdana" size="1" color="#54A800">'.$data[2].'</font></td> <td width="25%" align="center" height="20"> <font face="Verdana" size="1" color="#54A800">'.$data[3].'</font></td> <td width="25%" align="center" height="20"> <font size="1" face="Verdana" color="#54A800">[ <a href="contact.php?id='.$data[0].'">PM</a> ]</font></td> </tr>';}?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/14687-sql-help/#findComment-58586 Share on other sites More sharing options...
xyn Posted July 15, 2006 Author Share Posted July 15, 2006 Thanks pix. btw when i tried array it stayted the samealthough its probably becuase i done this:'.$data['id'][0].' rofl, but works now :]thanks Quote Link to comment https://forums.phpfreaks.com/topic/14687-sql-help/#findComment-58587 Share on other sites More sharing options...
pixy Posted July 15, 2006 Share Posted July 15, 2006 Lol, that [i]might[/i] cause a problem. Glad you got it worked out. Quote Link to comment https://forums.phpfreaks.com/topic/14687-sql-help/#findComment-58588 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.