*

Recent

Author Topic: no spaces in anything  (Read 15716 times)

Trasion

  • Guest
no spaces in anything
« on: July 21, 2009, 01:35:07 PM »


It should be titled:

"Traps, Mines and Sheep"

Why is it missing the coma, and spaces? I'd really like them to be in that. This part is on the left side column.

kurt

  • Developer
  • Hero Member
  • ******
  • Posts: 634
  • Force: +16/-1
Re: no spaces in anything
« Reply #1 on: July 21, 2009, 01:47:11 PM »
I don't have that code, it's something you did I believe. When you code it though, you can use 2 distinct name variables, first one for the link you build for it, and that one needs to have no spaces, the second can be the raw name right out of the SQL query which probably does have the spaces etc. Not seeing the code that makes it though I couldn't be more specific than that.

And I'm going AFK for a bit, so I won't see any new posts for at least an hour.

Trasion

  • Guest
Re: no spaces in anything
« Reply #2 on: July 21, 2009, 01:48:50 PM »
Okay, please let me know soon then. What piece of code do you need to see?

Here's the code for it.

Code: [Select]
    <table width="100%">
              <tr>
                <td class="header2">Random Game</td>
              </tr>
              <tr>
                <td class="content2"><?php

$r 
$db->query(sprintf('SELECT * FROM dd_games ORDER BY rand() LIMIT 0,1'));
echo 
'<table width=\'100%\' border=\'0\' align=\'center\'>
<tr>
</tr>'
;
$count 0;
while(
$in $db->fetch_row($r)){
$gamename ereg_replace('[^A-Za-z0-9]'''$in['name']);
if($seo_on == 1){
$playlink ''.$domain.'/play/'.$in['ID'].'-'.$gamename.'.html';
}else{
$playlink ''.$domain.'/index.php?action=play&amp;ID='.$in['ID'].'';
}
if(
$count%2==0){

       echo 
'<tr>
       <td width=\'50%\' valign=\'top\'>
      
       <table width=\'100%\' border=\'0\'>

       <tr> <center><a href=\''
.$playlink.'\'><b>'.$gamename.'</b></a></center><br />
       <td width=\'55\' height=\'55\' valign=\'top\'>
       <a href=\''
.$playlink.'\'>
       '
;
       if($in['type'] == 1){
       echo ' <center><img src=\''.$domain.'/'.$thumbsfolder.'/'.$in['thumb'].'\' width=\'50\' width=\'50\' border=\'1px solid #444444\'></center>';
       }else{
       echo ' <center><img src=\''.$in['thumburl'].'\' width=\'50\' width=\'50\' border=\'1px solid #444444\'></center>';
       }
      
       echo ' </a>
       </td></tr>
      
       </table>
</td>
'
;
}else{
 echo 
'';
}
$count++;
}
echo 
"</table>";
?>
&nbsp;</td>
              </tr>
            </table>

Please let me know how to fix this.
« Last Edit: July 21, 2009, 01:52:06 PM by Trasion »

Adam LaCombe

  • Sr. Member
  • ****
  • Posts: 433
  • Force: +17/-0
    • My Blog
Re: no spaces in anything
« Reply #3 on: July 21, 2009, 01:57:28 PM »
Try doing this:
Code: [Select]
   <table width="100%">
              <tr>
                <td class="header2">Random Game</td>
              </tr>
              <tr>
                <td class="content2"><?php

$r 
$db->query(sprintf('SELECT * FROM dd_games ORDER BY rand() LIMIT 0,1'));
echo 
'<table width=\'100%\' border=\'0\' align=\'center\'>
<tr>
</tr>'
;
$count 0;
while(
$in $db->fetch_row($r)){
$gamename $in['name'];
if($seo_on == 1){
$playlink ''.$domain.'/play/'.$in['ID'].'-'.$gamename.'.html';
}else{
$playlink ''.$domain.'/index.php?action=play&amp;ID='.$in['ID'].'';
}
if(
$count%2==0){

       echo 
'<tr>
       <td width=\'50%\' valign=\'top\'>
      
       <table width=\'100%\' border=\'0\'>

       <tr> <center><a href=\''
.$playlink.'\'><b>'.$gamename.'</b></a></center><br />
       <td width=\'55\' height=\'55\' valign=\'top\'>
       <a href=\''
.$playlink.'\'>
       '
;
       if($in['type'] == 1){
       echo ' <center><img src=\''.$domain.'/'.$thumbsfolder.'/'.$in['thumb'].'\' width=\'50\' width=\'50\' border=\'1px solid #444444\'></center>';
       }else{
       echo ' <center><img src=\''.$in['thumburl'].'\' width=\'50\' width=\'50\' border=\'1px solid #444444\'></center>';
       }
      
       echo ' </a>
       </td></tr>
      
       </table>
</td>
'
;
}else{
 echo 
'';
}
$count++;
}
echo 
"</table>";
?>
&nbsp;</td>
              </tr>
            </table>

I think that should work...

Trasion

  • Guest
Re: no spaces in anything
« Reply #4 on: July 21, 2009, 02:09:58 PM »
Wow. You guys are the most helpful guys I know, and that's surprising to find, especially with a free script that just started recently.

I have another question. I made so many threads in this section, so I'll ask here =p.

How can I show the persons avatar in the side column? What code do I use to display your own avatar?

Adam LaCombe

  • Sr. Member
  • ****
  • Posts: 433
  • Force: +17/-0
    • My Blog
Re: no spaces in anything
« Reply #5 on: July 21, 2009, 02:18:05 PM »
Actually I have already done that but before 1.3 so it was blah.. bc I tried making my own avatar option, didnt work out the best :D
but here it is:
Code: [Select]
<?php
echo '<ul class=\'catmenu\'>';

$tur $db->query('SELECT username, userid, plays, avatarfile FROM dd_users ORDER BY plays DESC LIMIT 0,15');
while($r $db->fetch_row($tur)){
echo '
<li><img src="avatars/'
.$r['avatarfile'].'" height="15" width="15" /> '.$r['username'].' - ('.$r['plays'].')</li>';
}
echo '

</ul>'
;
?>


Robbie

  • Sr. Member
  • ****
  • Posts: 343
  • Force: +16/-0
Re: no spaces in anything
« Reply #6 on: July 21, 2009, 02:22:02 PM »
Quote
Wow. You guys are the most helpful guys I know, and that's surprising to find, especially with a free script that just started recently.

Yes im proud of these guys they dont have the praise they deserve ....and we are not like other script sites ...we actively encourage users to become part of our community  !!

« Last Edit: July 21, 2009, 02:23:49 PM by admin »

Trasion

  • Guest
Re: no spaces in anything
« Reply #7 on: July 21, 2009, 02:25:19 PM »
Adam, that shows your avatars in the Top Users part. I want it just to show your avatar anywhere. :)

Adam LaCombe

  • Sr. Member
  • ****
  • Posts: 433
  • Force: +17/-0
    • My Blog
Re: no spaces in anything
« Reply #8 on: July 21, 2009, 02:30:36 PM »
What do you mean by everywhere?
Like everywhere meaning everywhere a username may be?
if so, you will have to do all of that but all you have to do is basically work with what I just gave you as a template.
SELECT * FROM dd_users
will pull everything from the table dd_users.
then once you have you're while in there ( while($variable1 = $db->fetch_row($variable)) )
Then just add in:
Code: [Select]
echo '<img src="avatars/'.$variable1['avatarfile'].'" height="15" width="15" />'; Is that what you meant?

EDIT:
Basic:
Code: [Select]
<?php
$tur 
$db->query('SELECT * FROM dd_users LIMIT 0,5');
while(
$r $db->fetch_row($tur)){
echo 
'<img src="avatars/'.$r['avatarfile'].'" height="15" width="15" />';
//end while
?>

or:
Code: [Select]
<?php
$id
=$_GET['id'];
$tur mysql_query("SELECT * FROM dd_users WHERE userid='$id'");
while(
$r mysql_fetch_array($tur)){
echo 
'<img src="avatars/'.$r['avatarfile'].'" height="15" width="15" />';
//end while
?>

« Last Edit: July 21, 2009, 02:37:23 PM by Adam »

Trasion

  • Guest
Re: no spaces in anything
« Reply #9 on: July 21, 2009, 02:37:14 PM »
Actually scratch that. Adam, you just showed me how to add the persons avatar beside their name in 'Top Users'. Now, if I renamed 'Top Users', to 'Top Highscores', and only showed 3 users on it. How could I add an image for the top place beside their name, as a gold trophy, second as silver, and third as bronze?

Say the images are located at...

'templates/default/images/trophy_gold.png'
'templates/default/images/trophy_silver.png'
'templates/default/images/trophy_bronze.png'

Do you know what I mean? Is this possible?

Adam LaCombe

  • Sr. Member
  • ****
  • Posts: 433
  • Force: +17/-0
    • My Blog
Re: no spaces in anything
« Reply #10 on: July 21, 2009, 02:41:01 PM »
Umm yes it is.
But I do not know the database structure for the highscore mod you're making.

Trasion

  • Guest
Re: no spaces in anything
« Reply #11 on: July 21, 2009, 02:46:15 PM »
You need to know that now? I just want it to kind of implement to the Top Users system. So the person who's name is listed at the top (most plays) gets a gold trophy beside his name. I can change it myself later for the highscores. But right now I just want it to be for the top plays.

Adam LaCombe

  • Sr. Member
  • ****
  • Posts: 433
  • Force: +17/-0
    • My Blog
Re: no spaces in anything
« Reply #12 on: July 21, 2009, 02:56:08 PM »
Well it could be something like:
Code: [Select]
....

$highscore=$sql[highscore];
while(){
if($highscore>15){
//Gold
}
if($highscore>10){
//silver
}
if($highscore>5){
//bronze
}

I think.. I dont know to much on the math part of PHP ( A.D.D. is a pain lol)
Kurt might be able to help you out on that one if what I posted was not what you were looking for.

if its for top plays:

Code: [Select]
<?php
echo '<ul class=\'catmenu\'>';

$tur $db->query('SELECT * FROM dd_users ORDER BY plays DESC LIMIT 0,15');
while(
$r $db->fetch_row($tur)){
echo 
'<li>';
$plays=$r[plays];
if(
$plays>15){
//Gold
}
if(
$plays>10){
//silver
}
if(
$plays>5){
//bronze
}
echo 
'
 '
.$r['username'].' - ('.$r['plays'].')</li>';
}
echo 
'</ul>';
?>


Trasion

  • Guest
Re: no spaces in anything
« Reply #13 on: July 21, 2009, 03:04:33 PM »
I don't want it for if you have 5 plays it shows. I want it so if you're the TOP player, it shows gold. Second top, silver. etc.

kurt

  • Developer
  • Hero Member
  • ******
  • Posts: 634
  • Force: +16/-1
Re: no spaces in anything
« Reply #14 on: July 21, 2009, 03:15:26 PM »
Yea, not knowing the structure does hinder somewhat. If you do an SQL query  order by number of wins desc limit 3 it would give you the basic data to work with. Then set up a counter variable and set it to 1. Then a while loop that posts the user info you want, and shows picture acording to what the variable is, then ads 1 to the variable befor checking of it loops again.

That make sense?