You are not logged in.

jaymo

Beginner

  • "jaymo" started this thread

Posts: 6

Activitypoints: 45

Level: 6 [?]

Experience: 252

Next Level: 282

  • Send private message

1

Saturday, July 31st 2010, 12:28pm

How can I get the money like this? $4,500 from $4500

I used to use the grpg but found many bugs and glitches. I'm going to create a new game with it but before I start there has been 1 thing bugging me for a while. The money shows up as say $5000 and I want it to say $5,000. Is there a simple way to change it?

If anyone could help, I also think you may be able to edit it in classes.php


PHP Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
<?php
function Get_ID($username){
    $result mysql_query("SELECT * FROM `grpgusers` WHERE `username` = '".$username."'");
    $worked mysql_fetch_array($result);
    return $worked['id'];
}

function mrefresh($url$time="1"){
    echo '<meta http-equiv="refresh" content="'.$time.';url='.$url.'">';
}

function car_popup($text$id) {
    return  "<a href='#' onclick=\"javascript:window.open( 'cardesc.php?id=".$id."', '60', 'left = 20, top = 20, width = 400, height = 400, toolbar = 0, resizable = 0, scrollbars=1' );\">".$text."</a>";
}

function item_popup($text$id) {
    return  "<a href='#' onclick=\"javascript:window.open( 'description.php?id=".$id."', '60', 'left = 20, top = 20, width = 400, height = 400, toolbar = 0, resizable = 0, scrollbars=1' );\">".$text."</a>";
}

function prettynum($num,$dollar="0") {
// Basic send a number or string to this and it will add commas. If you want a dollar sign added to the
// front and it is a number add a 1 for the 2nd variable.
// Example prettynum(123452838,1)  will return $123,452,838 take out the ,1 and it looses the dollar sign.
        $out=strrev( (string)preg_replace'/(\d{3})(?=\d)(?!\d*\.)/''$1,' strrev$num ) ) );
        if ($dollar && is_numeric($num)){
            $out"$".$out;
        }
    return $out;
}

function Check_Item($itemid$userid){
    $result mysql_query("SELECT * FROM `inventory` WHERE `userid`='$userid' AND `itemid`='$itemid'");
    $worked mysql_fetch_array($result);
    
    if($worked['quantity'] > 0){
        return $worked['quantity'];
    } else {
        return 0;
    }
}

function Check_Land($city$userid){
    $result mysql_query("SELECT * FROM `land` WHERE `userid`='".$userid."' AND `city`='".$city."'");
    $worked mysql_fetch_array($result);
        
    if($worked['quantity'] > 0){
        return $worked['quantity'];
    } else {
        return 0;
    }
}
//userid    companyid    howmany
function Give_Share($stock$userid$quantity="1"){
    $result mysql_query("SELECT * FROM `shares` WHERE `userid`='".$userid."' AND `companyid`='".$stock."'");
    $worked mysql_fetch_array($result);
    $itemexist mysql_num_rows($result);
    
    if($itemexist == 0){
        $resultmysql_query("INSERT INTO `shares` (`companyid`, `userid`, `amount`)"."VALUES ('$stock', '$userid', '$quantity')");
    } else {
        $quantity $quantity $worked['amount'];
        $result mysql_query("UPDATE `shares` SET `amount` = '".$quantity."' WHERE `userid`='$userid' AND `companyid`='$stock'");
    }
}

function Take_Share($stock$userid$quantity="1"){
    $result mysql_query("SELECT * FROM `shares` WHERE `userid`='".$userid."' AND `companyid`='".$stock."'");
    $worked mysql_fetch_array($result);
    $itemexist mysql_num_rows($result);
    
    if($itemexist != 0){
        $quantity $worked['amount'] - $quantity;
        if($quantity 0){
            $result mysql_query("UPDATE `shares` SET `amount` = '".$quantity."' WHERE `userid`='$userid' AND `companyid`='$stock'");
        } else {
            $result mysql_query("DELETE FROM `shares` WHERE `userid`='$userid' AND `companyid`='$stock'");
        }
    }
}
    

function Check_Share($stock$userid){
    $result mysql_query("SELECT * FROM `shares` WHERE `userid`='".$userid."' AND `companyid`='".$stock."'");
    $worked mysql_fetch_array($result);
        
    if($worked['amount'] > 0){
        return $worked['amount'];
    } else {
        return 0;
    }
}

function Give_Land($city$userid$quantity="1"){
    $result mysql_query("SELECT * FROM `land` WHERE `userid`='".$userid."' AND `city`='".$city."'");
    $worked mysql_fetch_array($result);
    $itemexist mysql_num_rows($result);
    
    if($itemexist == 0){
        $resultmysql_query("INSERT INTO `land` (`city`, `userid`, `amount`)"."VALUES ('$city', '$userid', '$quantity')");
    } else {
        $quantity $quantity $worked['amount'];
        $result mysql_query("UPDATE `land` SET `amount` = '".$quantity."' WHERE `userid`='$userid' AND `city`='$city'");
    }
}

function Take_Land($city$userid$quantity="1"){
    $result mysql_query("SELECT * FROM `land` WHERE `userid`='".$userid."' AND `city`='".$city."'");
    $worked mysql_fetch_array($result);
    $itemexist mysql_num_rows($result);
    
    if($itemexist != 0){
        $quantity $worked['amount'] - $quantity;
        if($quantity 0){
            $$result mysql_query("UPDATE `land` SET `amount` = '".$quantity."' WHERE `userid`='$userid' AND `city`='$city'");
        } else {
            $result mysql_query("DELETE FROM `land` WHERE `userid`='$userid' AND `city`='$city'");
        }
    }
}
    
function Give_Item($itemid$userid$quantity="1"){
    $result mysql_query("SELECT * FROM `inventory` WHERE `userid`='$userid' AND `itemid`='$itemid'");
    $worked mysql_fetch_array($result);
    $itemexist mysql_num_rows($result);
    
    if($itemexist == 0){
        $resultmysql_query("INSERT INTO `inventory` (`itemid`, `userid`, `quantity`)"."VALUES ('$itemid', '$userid', '$quantity')");
    } else {
        $quantity $quantity $worked['quantity'];
        $result mysql_query("UPDATE `inventory` SET `quantity` = '".$quantity."' WHERE `userid`='$userid' AND `itemid`='$itemid'");
    }
}

function Take_Item($itemid$userid$quantity="1"){
    $result mysql_query("SELECT * FROM `inventory` WHERE `userid`='$userid' AND `itemid`='$itemid'");
    $worked mysql_fetch_array($result);
    $itemexist mysql_num_rows($result);
    
    if($itemexist != 0){
        $quantity $worked['quantity'] - $quantity;
        if($quantity 0){
            $result mysql_query("UPDATE `inventory` SET `quantity` = '".$quantity."' WHERE `userid`='$userid' AND `itemid`='$itemid'");
        } else {
            $result mysql_query("DELETE FROM `inventory` WHERE `userid`='$userid' AND `itemid`='$itemid'");
        }
    }
}


function Message($text){

    return '<tr><td class="contenthead">.: Important Message</td></tr>

<tr><td class="contentcontent">'.$text.'</td></tr>';

}



function Send_Event ($id$text){

  $timesent time();

  $resultmysql_query("INSERT INTO `events` (`to`, `timesent`, `text`)".

  "VALUES ('$id', '$timesent', '$text')");

}



function Is_User_Banned ($id) {

    $result mysql_query("SELECT * FROM `bans` WHERE `id`='$id'");

    return mysql_num_rows($result);

}

function Why_Is_User_Banned ($id) {

    $result mysql_query("SELECT * FROM `bans` WHERE `id`='$id'");

    $worked mysql_fetch_array($result);

    return $worked['reason'];

}

function Radio_Status () {

    $result mysql_query("SELECT * FROM `serverconfig`");

    $worked mysql_fetch_array($result);

    return $worked['radio'];

}



function howlongago($ts) {
   $ts=time()-$ts;
   if ($ts<1)
       // <1 second
       return " NOW";
   elseif ($ts==1)
       // <1 second
       return $ts." second";
   elseif ($ts<60)
       // <1 minute
       return $ts." seconds";
     elseif ($ts<120)
       // 1 minute
      return "1 minute";
    
     elseif ($ts<60*60)
       // <1 hour
       return floor($ts/60)." minutes";
   elseif ($ts<60*60*2)
       // <2 hour
       return "1 hour";
     elseif ($ts<60*60*24)
       // <24 hours = 1 day
       return floor($ts/(60*60))." hours";
     elseif ($ts<60*60*24*2)
       // <2 days
       return "1 day";
     elseif ($ts<(60*60*24*7))
       // <7 days = 1 week
         return floor($ts/(60*60*24))." days";
   elseif ($ts<60*60*24*30.5)
       // <30.5 days ~  1 month
       return floor($ts/(60*60*24*7))." weeks";
     elseif ($ts<60*60*24*365)
       // <365 days = 1 year
       return floor($ts/(60*60*24*30.5))." months";
   else
       // more than 1 year
       return floor($ts/(60*60*24*365))." years";
};

function howlongtil($ts) {
   $ts=$ts time();
   if ($ts<1)
       // <1 second
       return " NOW";
   elseif ($ts==1)
       // <1 second
       return $ts." second";
   elseif ($ts<60)
       // <1 minute
       return $ts." seconds";
     elseif ($ts<120)
       // 1 minute
      return "1 minute";
    
     elseif ($ts<60*60)
       // <1 hour
       return floor($ts/60)." minutes";
   elseif ($ts<60*60*2)
       // <2 hour
       return "1 hour";
     elseif ($ts<60*60*24)
       // <24 hours = 1 day
       return floor($ts/(60*60))." hours";
     elseif ($ts<60*60*24*2)
       // <2 days
       return "1 day";
     elseif ($ts<(60*60*24*7))
       // <7 days = 1 week
         return floor($ts/(60*60*24))." days";
   elseif ($ts<60*60*24*30.5)
       // <30.5 days ~  1 month
       return floor($ts/(60*60*24*7))." weeks";
     elseif ($ts<60*60*24*365)
       // <365 days = 1 year
       return floor($ts/(60*60*24*30.5))." months";
   else
       // more than 1 year
       return floor($ts/(60*60*24*365))." years";
};



//level 2 - 500

//level 3 - 1500

//level 4 - 3500

//level 5 - 6000





function experience($L) {

  $a=0;

  $end=0;

  for($x=1$x<$L$x++) {

    $a += floor($x+1500*pow(4, ($x/7)));

  }

  return floor($a/4);

}



function Get_The_Level($exp) {

  $a=0;

  $end =0;

  for($x=1; ($end==&& $x<100); $x++) {

    $a += floor($x+1500*pow(4, ($x/7)));

    if ($exp >= floor($a/4)){

    } else {
    
      return $x;

      $end=1;

    }

  }

}



function Get_Max_Exp($L){

$end=0;

 if ($exp == 0){

    return 457;

    $end =1;

  }

    for($L=1;($L<100 && $end==0);$L++) {

      $exp experience($L);

      //echo $exp;

      if ($exp >= $user_class->exp){

        return $exp;

        $end=1;

      }

    }

}



class User_Stats {

 function User_Stats($wutever){

    $result mysql_query("SELECT * FROM `grpgusers` ORDER BY `username` ASC");

    $result3 mysql_query("SELECT * FROM `grpgusers` ORDER BY `username` ASC");



        while($line mysql_fetch_array($resultMYSQL_ASSOC)) {

            $secondsago time()-$line['lastactive'];

            if ($secondsago<=300) {

                $this->playersloggedin++;

            }

        }



        while($line3 mysql_fetch_array($result3MYSQL_ASSOC)) {

            $secondsago time()-$line3['lastactive'];

            if ($secondsago<=86400) {

                $this->playersonlineinlastday++;

            }

        }

    $result2 mysql_query("SELECT * FROM `grpgusers`");

    $this->playerstotal mysql_num_rows($result2);

  }

}





class Gang{

     function Gang($id) {

    $result mysql_query("SELECT * FROM `gangs` WHERE `id`='$id'");

    $worked mysql_fetch_array($result);

    $gangcheck mysql_query("SELECT * FROM `grpgusers` WHERE `gang`='".$id."'");



    $this->id $worked['id'];

    $this->members mysql_num_rows($gangcheck);

    $this->name $worked['name'];

    $this->formattedname "<a href='viewgang.php?id=".$worked['id']."'>".$worked['name']."</a>";

    $this->description $worked['description'];

    $this->leader $worked['leader'];

    $this->tag $worked['tag'];

    $this->exp $worked['exp'];

    $this->level Get_The_Level($this->exp);

    $this->vault $worked['vault'];

    $gangcheck mysql_query("SELECT * FROM `grpgusers` WHERE `gang`='".$line['id']."'");

    $members mysql_num_rows($gangcheck);



    }



}







class User {

  function User($id) {

    $result mysql_query("SELECT * FROM `grpgusers` WHERE `id`='$id'");

    $worked mysql_fetch_array($result);

    $result2 mysql_query("SELECT * FROM `gangs` WHERE `id`='".$worked['gang']."'");

    $worked2 mysql_fetch_array($result2);

    $result3 mysql_query("SELECT * FROM `cities` WHERE `id`='".$worked['city']."'");

    $worked3 mysql_fetch_array($result3);

       $result4 mysql_query("SELECT * FROM `houses` WHERE `id`='".$worked['house']."'");

    $worked4 mysql_fetch_array($result4);

    $result5 mysql_query("SELECT * FROM `inventory` WHERE `userid` = '".$id."' ORDER BY `userid` DESC");

    $checkcocaine mysql_query("SELECT * FROM `effects` WHERE `userid`='".$id."' AND `effect`='Cocaine'");

    $cocaine mysql_num_rows($checkcocaine);

    $speedbonus = ($cocaine 0) ? (floor($worked['speed'] * .30)) : 0;

    $this->weaponoffense 0;
    $this->weaponname "fists";
    $this->armordefense 0;
    if($worked["eqweapon"] != 0){
        $result6 mysql_query("SELECT * FROM `items` WHERE `id`='".$worked['eqweapon']."' LIMIT 1");
        $worked6 mysql_fetch_array($result6);
        $this->eqweapon $worked6['id'];
        $this->weaponoffense $worked6['offense'];
        $this->weaponname $worked6['itemname'];
        $this->weaponimg $worked6['image'];
    }
    if($worked["eqarmor"] != 0){
        $result6 mysql_query("SELECT * FROM `items` WHERE `id`='".$worked['eqarmor']."' LIMIT 1");
        $worked6 mysql_fetch_array($result6);
        $this->eqarmor $worked6['id'];
        $this->armordefense $worked6['defense'];
        $this->armorname $worked6['itemname'];
        $this->armorimg $worked6['image'];
    }

    $this->moddedstrength $worked['strength'] * ($this->weaponoffense .01 1);

    $this->moddeddefense $worked['defense'] * ($this->armordefense .01 1);



    $this->id $worked['id'];

    $this->ip $worked['ip'];

    $this->style = ($worked['style'] > 0) ? $worked['style'] : "1";

    $this->speedbonus $speedbonus;

    $this->username $worked['username'];
    
    $this->marijuana $worked['marijuana'];
    
    $this->potseeds $worked['potseeds'];

    $this->cocaine $worked['cocaine'];

    $this->nodoze $worked['nodoze'];

    $this->genericsteroids $worked['genericsteroids'];

    $this->hookers $worked['hookers'];

    $this->exp $worked['exp'];

    $this->level Get_The_Level($this->exp);

    $this->maxexp experience($this->level +1);

    $this->exppercent = ($this->exp == 0) ? floor(($this->exp $this->maxexp) * 100);

    $this->formattedexp $this->exp." / ".$this->maxexp." [".$this->exppercent."%]";

    $this->money $worked['money'];

    $this->bank $worked['bank'];

    $this->whichbank $worked['whichbank'];

    $this->hp $worked['hp'];

    $this->maxhp $this->level 50;

    $this->hppercent floor(($this->hp $this->maxhp) * 100);

    $this->formattedhp $this->hp." / ".$this->maxhp." [".$this->hppercent."%]";

    $this->energy $worked['energy'];

    $this->maxenergy $this->level;

    $this->energypercent floor(($this->energy $this->maxenergy) * 100);

    $this->formattedenergy $this->energy." / ".$this->maxenergy." [".$this->energypercent."%]";

    $this->nerve $worked['nerve'];

    $this->maxnerve $this->level;

    $this->nervepercent floor(($this->nerve $this->maxnerve) * 100);

    $this->formattednerve $this->nerve." / ".$this->maxnerve." [".$this->nervepercent."%]";

    $this->workexp $worked['workexp'];

    $this->strength $worked['strength'];

    $this->defense $worked['defense'];

    $this->speed $worked['speed'] + $speedbonus;

    $this->totalattrib $this->speed $this->strength $this->defense;

    $this->battlewon $worked['battlewon'];

    $this->battlelost $worked['battlelost'];

    $this->battletotal $this->battlewon $this->battlelost;

    $this->battlemoney $worked['battlemoney'];

    $this->crimesucceeded $worked['crimesucceeded'];

    $this->crimefailed $worked['crimefailed'];

    $this->crimetotal $this->crimesucceeded $this->crimefailed;

    $this->crimemoney $worked['crimemoney'];

    $this->lastactive $worked['lastactive'];

    $this->age howlongago($worked['signuptime']);

    $this->formattedlastactive howlongago($this->lastactive) . " ago";

    $this->points $worked['points'];

    $this->rmdays $worked['rmdays'];

    $this->signuptime $worked['signuptime'];

    $this->lastactive $worked['lastactive'];

    $this->house $worked['house'];

    $this->housename = ($worked4['name'] == "") ? "Homeless" $worked4['name'];

    $this->houseawake = ($worked4['name']== "") ? 100 $worked4['awake'];

    $this->awake $worked['awake'];

    $this->maxawake $this->houseawake;

    $this->awakepercent floor(($this->awake $this->maxawake) * 100);

    $this->formattedawake $this->awake." / ".$this->maxawake." [".$this->awakepercent."%]";

    $this->email $worked['email'];

    $this->house $worked['house'];

    $this->admin $worked['admin'];

    $this->quote $worked['quote'];
    
    $this->avatar $worked['avatar'];

    $this->gang $worked['gang'];

    $this->gangname $worked2['name'];

    $this->gangleader $worked2['leader'];

    $this->gangtag $worked2['tag'];

    $this->gangdescription $worked2['description'];

    $this->formattedgang "<a href='viewgang.php?id=".$this->gang."'>".$this->gangname."</a>";

    $this->city $worked['city'];

    $this->cityname $worked3['name'];

    $this->jail $worked['jail'];

    $this->job $worked['job'];

    $this->hospital $worked['hospital'];

    $this->searchdowntown $worked['searchdowntown'];



    if ($this->gang != 0){

        $this->formattedname .= "<a href='viewgang.php?id=".$this->gang."'";

        $this->formattedname .= ($this->gangleader == $this->username) ? " title='Gang Leader'>[<b>".$this->gangtag."</b>]</a>" ">[".$this->gangtag."]</a>";

    }

    if ($this->rmdays != 0){

         $this->type "Respected Mobster";

        $whichfont "green";

    } else {

         $this->type "Regular Mobster";

    }

    if ($this->admin == 1) {

        $this->type "Admin";

        $whichfont "blue";

    }

    if ($this->admin == 2) {

        $this->type "Staff";

    }

    if ($this->admin == 3) {

        $this->type "Pre
        ent";

        $whichfont "red";

    }

    if ($this->admin == 4) {

        $this->type "Congress";

        $whichfont "red";

    }

    if ($this->rmdays 0){

        $this->formattedname .= "<b><a title='Respected Mobster [".$this->rmdays." RM Days Left]' href='profiles.php?id=".$this->id."'><font color = '".$whichfont."'>".$this->username."</a></font></b>";

    } elseif ($this->admin != 0) {

        $this->formattedname .= "<b><a href='profiles.php?id=".$this->id."'><font color = '".$whichfont."'>".$this->username."</a></font></b>";

    } else {

        $this->formattedname .= "<a href='profiles.php?id=".$this->id."'><font color = '".$whichfont."'>".$this->username."</a></font>";

    }

    if (time() - $this->lastactive 300) {

        $this->formattedonline"<font style='color:green;padding:2px;font-weight:bold;'>[online]</font>";

    } else {

        $this->formattedonline"<font style='color:red;padding:2px;font-weight:bold;'>[offline]</font>";

    }

  }

}

/*

$result2 = mysql_query("SELECT * FROM `gangs` WHERE `id`='$gang'");

$worked2 = mysql_fetch_array($result2);

$gangname = $worked2['name'];

$gangleader = $worked2['leader'];

*/

?>

Dave Macaulay

Professional

  • "Dave Macaulay" is male

Posts: 1,313

Activitypoints: 7,050

Location: Brighton, United Kingdom

Level: 39 [?]

Experience: 1.684.414

Next Level: 1.757.916

  • Send private message

2

Saturday, July 31st 2010, 2:10pm

You would do..

PHP Source code

1
number_format(4500); //Will return 4,500


Considering you probably want it to be a bit easier write a simple function

PHP Source code

1
2
3
function MoneyFormat($amt,$sign='$') {
return $sign.number_format($amt);
}

This post by "Danny696" (Saturday, July 31st 2010, 4:13pm) has been deleted by user "Jordan Palmer" (Sunday, August 1st 2010, 6:23pm)

jaymo

Beginner

  • "jaymo" started this thread

Posts: 6

Activitypoints: 45

Level: 6 [?]

Experience: 252

Next Level: 282

  • Send private message

4

Wednesday, August 4th 2010, 2:17pm

thanks

Paul

Sage

Posts: 4,335

Activitypoints: 24,110

Occupation: Freelancer

Level: 44 [?]

Experience: 3.907.744

Next Level: 4.297.834

  • Send private message

5

Wednesday, August 4th 2010, 2:58pm

I use a bit more of a complex function for mine but that's about right :)

jaymo

Beginner

  • "jaymo" started this thread

Posts: 6

Activitypoints: 45

Level: 6 [?]

Experience: 252

Next Level: 282

  • Send private message

6

Sunday, August 15th 2010, 6:20pm

I can't get this to work, I need a bit more guidance on where to put these codes.

Dave Macaulay

Professional

  • "Dave Macaulay" is male

Posts: 1,313

Activitypoints: 7,050

Location: Brighton, United Kingdom

Level: 39 [?]

Experience: 1.684.414

Next Level: 1.757.916

  • Send private message

7

Sunday, August 15th 2010, 6:39pm

I can't get this to work, I need a bit more guidance on where to put these codes.


Well basically find say the users money and do this ->

PHP Source code

1
money_formatter($user->money);

Paul Evans

Trainee

  • "Paul Evans" is male

Posts: 91

Activitypoints: 465

Location: England

Occupation: Developer

Level: 11 [?]

Experience: 2.046

Next Level: 2.074

  • Send private message

8

Sunday, August 15th 2010, 6:45pm

ok a example would be

PHP Source code

1
2
3
4
5
6
7
$var 1348// this could also be result it's just for the example
# echo value
echo number_format($var); // results in 1,348
# or maybe you want it in a query =>
mysql_query('UPDATE `table` SET `field` = "'.number_format($var).'" WHERE `field` = "Clause"'); // results in UPDATE `table` SET `field` = "1,348" WHERE `field` = "Clause"
# You could also do
echo '$'.$var// Results in $1,348

but the best bet is to make your own function similar to this example

PHP Source code

1
2
3
4
5
6
7
8
9
function currency_format ($amount$ymbol) {
        $amount = ( isset($amount) && is_numeric($amount) ) ? abs($amount) : ;
    if ( !empty($amount) && (!empty($ymbol) && strlen($ymbol) < 3) ) {
        RETURN $ymbol.$amount;
    } else {
        RETURN FALSE;
}
# Testing:
echo currency_format('19288','$'); // Results in $19,288

just a quick example

This post has been edited 1 times, last edit by "Paul Evans" (Aug 15th 2010, 7:35pm)


  • "Haunted Dawg" is male

Posts: 3,041

Activitypoints: 15,775

Location: South Africa

Occupation: Website Developer/Part time job

Level: 42 [?]

Experience: 2.885.648

Next Level: 3.025.107

  • Send private message

9

Sunday, August 15th 2010, 7:14pm

mysql_query('UPDATE `table` SET `field` = "'.$var.'" WHERE `field` = "Clause"'); // results in UPDATE `table` SET `field` = "1,348" WHERE `field` = "Clause"

Would actualy be

mysql_query('UPDATE `table` SET `field` = "'.$var.'" WHERE `field` = "Clause"'); // results in UPDATE `table` SET `field` = "1348" WHERE `field` = "Clause"

Deadly Killah

This game has been in design since late 2008, and has carried out alot of designing done to it, some nice modifications, very unique in its own way. No current date set for completion.
DeadlyKillah: 66%


Limited Time Offer!!!

Offer: PSD to HTML Slicing

from Haunted Dawg (Monday, July 26th 2010, 5:15pm - 7 Comments) - General

Hi there, i am currently offering for a limited time of 2 month's for PSD Slicin...

 


For Hire

Freelancer for hire. Currently develop PHP, SQL, (X)HTML, JavaScript, Ajax. PM For price's and/or quotes.

Limited Time Offer!!!

Offer: PSD to HTML Slicing

from Haunted Dawg (Monday, July 26th 2010, 5:15pm - 7 Comments) - General

Hi there, i am currently offering for a limited time of 2 month's for PSD Slicin...

 


Modifications


MCCodes:

Offer: Highlow

from Haunted Dawg (Tuesday, August 3rd 2010, 7:58pm - 2 Comments) - MCCodes Mods

Hi there and welcome to my market entry. Today, i am offering my highlow modifi...

 

Any Other:

Offer: PSD to HTML Slicing

from Haunted Dawg (Monday, July 26th 2010, 5:15pm - 7 Comments) - General

Hi there, i am currently offering for a limited time of 2 month's for PSD Slicin...

 



Paul Evans

Trainee

  • "Paul Evans" is male

Posts: 91

Activitypoints: 465

Location: England

Occupation: Developer

Level: 11 [?]

Experience: 2.046

Next Level: 2.074

  • Send private message

10

Sunday, August 15th 2010, 7:37pm

Good point Haunted Dawg but would it not have been easier to just PM me rather than publicly announce a typo and waste two posts (including this one). Any reply to my PM box please.

Sorry for the posts Jaymo, hope it helps.

monoxide

Beginner

Posts: 11

Activitypoints: 70

Level: 8 [?]

Experience: 645

Next Level: 674

  • Send private message

11

Tuesday, August 17th 2010, 7:57pm

it's there here on line 20

Source code

1
2
3
4
5
6
7
8
9
10
function prettynum($num,$dollar="0") {
// Basic send a number or string to this and it will add commas. If you want a dollar sign added to the
// front and it is a number add a 1 for the 2nd variable.
// Example prettynum(123452838,1)  will return $123,452,838 take out the ,1 and it looses the dollar sign.
        $out=strrev( (string)preg_replace( '/(\d{3})(?=\d)(?!\d*\.)/', '$1,' , strrev( $num ) ) );
        if ($dollar && is_numeric($num)){
            $out= "$".$out;
        }
    return $out;
}


insert prettynum() functions around the number you want to add commas to
for ex $ ".$worked['money']." returns $10000
insert $".prettynum($worked['money'])." and it will be $10,000

and to not put the $ in front, just put ".prettynum($worked['money'],1)." and that will place a dollar sign outside of your number

Paul Evans

Trainee

  • "Paul Evans" is male

Posts: 91

Activitypoints: 465

Location: England

Occupation: Developer

Level: 11 [?]

Experience: 2.046

Next Level: 2.074

  • Send private message

12

Tuesday, August 17th 2010, 8:01pm

I gotta ask why the use of strrev?

monoxide

Beginner

Posts: 11

Activitypoints: 70

Level: 8 [?]

Experience: 645

Next Level: 674

  • Send private message

13

Tuesday, August 17th 2010, 8:11pm

gonna have to ask publius :P

Similar threads

Used tags

money change grpg