Skocz do zawartości

Witamy w Nieoficjalnym polskim support'cie AMX Mod X

Witamy w Nieoficjalnym polskim support'cie AMX Mod X, jak w większości społeczności internetowych musisz się zarejestrować aby móc odpowiadać lub zakładać nowe tematy, ale nie bój się to jest prosty proces w którym wymagamy minimalnych informacji.
  • Rozpoczynaj nowe tematy i odpowiedaj na inne
  • Zapisz się do tematów i for, aby otrzymywać automatyczne uaktualnienia
  • Dodawaj wydarzenia do kalendarza społecznościowego
  • Stwórz swój własny profil i zdobywaj nowych znajomych
  • Zdobywaj nowe doświadczenia

Dołączona grafika Dołączona grafika

Guest Message by DevFuse
 

Zdjęcie
PHP

Generator liczb

php

  • Nie możesz napisać tematu
  • Zaloguj się, aby dodać odpowiedź
8 odpowiedzi w tym temacie

#1 mozor

    Zaawansowany

  • Użytkownik

Reputacja: 1
Nowy

  • Postów:105
Offline

Napisano 05.08.2012 11:29

Witam,

znalazłem w internecie taki o to generator liczb.
Chciał bym żeby nie pokazywało liczb po przecinku, jak to zrobić.
Proszę o pomoc.
<?php
if (!$_POST['submit'])
{
//form not submitted, display form
?>
<form action="<?php echo $SERVER['PHP_SELF']; ?>"
method="post">
<br />
This is a DECIMAL random number generator that generates numbers specified by minimum and maximum value.<br />
For example you would like to generate random numbers between 99.75 and 100.25<br />
Example of this generated decimal random number will be 99.85. 100.21, 100.01, 99.98 etc. <br />
All you need is to specify how many random numbers you need, then also the range eg. minimum and maximum values. Fill up the form and <br />
tool will automatically produce the numbers to you. <br />
This tool may contain repeated numbers and if you like uniquely produced numbers, I will create one in the future. <br />
However you can use Excel to provide unique filtering of the produced set of random numbers. <br />
This tool will give two decimal places of the result.
<br /><br />
Given:
<br />
Wpisz ile liczb ma się pokazać <input type="text" name="amount" size="10">
<br />
<br />
Wpisz maksymalną wartość liczby: <input type="text" name="max" size="10">
<br />
<br />
Wpisz minimalną wartość liczby: <input type="text" name="min" size="10">
<br />
<br />
<input type="submit" name="submit" value="Generuj!">
</form>
<br />
<br />
<br />
To narzędzie zostało stworzone przez: <a href="link">.....</a>
<br />
<?php
}
else
{
//form submitted, grab the data from POST
$amount =trim($_POST['amount']);
$max =trim($_POST['max']);
$min =trim($_POST['min']);
//test if it contains some data.
if (((isset($amount)) && !(trim($amount) == "") && !(trim($max) == "") && !(trim($min) == "")) && ((is_numeric($amount)) && (is_numeric($max)) && (is_numeric($min)) && ($max > $min)))
{
//form input is either not empty and is numeric, process values
echo '<h2>Below are the generated decimal random numbers:</h2><br /><br />';
$maxadjusted = $max * 100;
$minadjusted = $min * 100;
$i = 1;
while ($i <= $amount) {
$random =mt_rand($minadjusted,$maxadjusted);
$number =1*  $random;
$i++;
echo round($number,2);
echo '<br />';
}
echo '<br />';
echo '<br />';
echo 'You have set max value to: &nbsp;'.$max;
echo '<br />';
echo 'You have set min value to: &nbsp;'.$min;
echo '<br />';
echo 'Amount of random numbers generated: &nbsp;'.$amount;
echo '<br />';
echo '<br />';
echo '<a href="/decimalrandomnumbergenerator.php">Try again this tool</a><br />';
}
else
{
//something is wrong with the inputted data
echo 'Please double check inputted data, it seems you either enter a blank data, wrong captcha, inputted a non-numeric value or inputted a value in a maximum field but is actually a minimum than your minimum set value.';
echo '<br />';
echo '<a href="/decimalrandomnumbergenerator.php">Click here to input data again.</a>';
}
}
?>

  • +
  • -
  • 0

#2 Gość_21977_*

  • Gość

Reputacja: 0

Offline

Napisano 05.08.2012 12:44

O ile dobrze zrozumiałem, to zamień
echo round($number,2);
na
echo round($number);


#3 mozor

    Zaawansowany

  • Autor tematu
  • Użytkownik

Reputacja: 1
Nowy

  • Postów:105
Offline

Napisano 05.08.2012 21:03

Wywala mi wtedy taki błąd.

Parse error: syntax error, unexpected T_ECHO in /virtual/n/i/xxx/losowanie.php on line 55



Gdzie xxx to moja strona
  • +
  • -
  • 0

#4 speedkill

    Godlike

  • Przyjaciel

Reputacja: 1 592
Godlike

  • Postów:2 733
  • GG:
  • Steam:steam
  • Imię:Michał
  • Lokalizacja:Prudnik
Offline

Napisano 05.08.2012 21:07

Pokaż kod, jak to zrobiłeś.
  • +
  • -
  • 0

If you can dream it, you can do it.


#5 mozor

    Zaawansowany

  • Autor tematu
  • Użytkownik

Reputacja: 1
Nowy

  • Postów:105
Offline

Napisano 06.08.2012 17:40

<?php
if (!$_POST['submit'])
{
//form not submitted, display form
?>
<form action="<?php echo $SERVER['PHP_SELF']; ?>"
method="post">
<br />
This is a DECIMAL random number generator that generates numbers specified by minimum and maximum value.<br />
For example you would like to generate random numbers between 99.75 and 100.25<br />
Example of this generated decimal random number will be 99.85. 100.21, 100.01, 99.98 etc. <br />
All you need is to specify how many random numbers you need, then also the range eg. minimum and maximum values. Fill up the form and <br />
tool will automatically produce the numbers to you. <br />
This tool may contain repeated numbers and if you like uniquely produced numbers, I will create one in the future. <br />
However you can use Excel to provide unique filtering of the produced set of random numbers. <br />
This tool will give two decimal places of the result.
<br /><br />
Given:
<br />
Wpisz ile liczb ma się pokazać <input type="text" name="amount" size="10">
<br />
<br />
Wpisz maksymalną wartość liczby: <input type="text" name="max" size="10">
<br />
<br />
Wpisz minimalną wartość liczby: <input type="text" name="min" size="10">
<br />
<br />
<input type="submit" name="submit" value="Generuj!">
</form>
<br />
<br />
<br />
To narzędzie zostało stworzone przez: <a href="link">.....</a>
<br />
<?php
}
else
{
//form submitted, grab the data from POST
$amount =trim($_POST['amount']);
$max =trim($_POST['max']);
$min =trim($_POST['min']);
//test if it contains some data.
if (((isset($amount)) && !(trim($amount) == "") && !(trim($max) == "") && !(trim($min) == "")) && ((is_numeric($amount)) && (is_numeric($max)) && (is_numeric($min)) && ($max > $min)))
{
//form input is either not empty and is numeric, process values
echo '<h2>Below are the generated decimal random numbers:</h2><br /><br />';
$maxadjusted = $max * 100;
$minadjusted = $min * 100;
$i = 1;
while ($i <= $amount) {
$random =mt_rand($minadjusted,$maxadjusted);
$number =1*  $random;
$i++;
echo round ($number);
echo '<br />';
}
echo '<br />';
echo '<br />';
echo 'You have set max value to: &nbsp;'.$max;
echo '<br />';
echo 'You have set min value to: &nbsp;'.$min;
echo '<br />';
echo 'Amount of random numbers generated: &nbsp;'.$amount;
echo '<br />';
echo '<br />';
echo '<a href="/decimalrandomnumbergenerator.php">Try again this tool</a><br />';
}
else
{
//something is wrong with the inputted data
echo 'Please double check inputted data, it seems you either enter a blank data, wrong captcha, inputted a non-numeric value or inputted a value in a maximum field but is actually a minimum than your minimum set value.';
echo '<br />';
echo '<a href="/decimalrandomnumbergenerator.php">Click here to input data again.</a>';
}
}
?>


Mógł by mi ktoś to zrobić ?

Użytkownik mozor edytował ten post 06.08.2012 17:54

  • +
  • -
  • 0

#6 Gość_21977_*

  • Gość

Reputacja: 0

Offline

Napisano 06.08.2012 18:07

Pomijając kwestię samego kodu,
<?php
if (!$_POST['submit'])
{
//form not submitted, display form
?>
<form action="<?php echo $SERVER['PHP_SELF']; ?>"
method="post">
<br />
This is a DECIMAL random number generator that generates numbers specified by minimum and maximum value.<br />
For example you would like to generate random numbers between 99.75 and 100.25<br />
Example of this generated decimal random number will be 99.85. 100.21, 100.01, 99.98 etc. <br />
All you need is to specify how many random numbers you need, then also the range eg. minimum and maximum values. Fill up the form and <br />
tool will automatically produce the numbers to you. <br />
This tool may contain repeated numbers and if you like uniquely produced numbers, I will create one in the future. <br />
However you can use Excel to provide unique filtering of the produced set of random numbers. <br />
This tool will give two decimal places of the result.
<br /><br />
Given:
<br />
Wpisz ile liczb ma się pokazać <input type="text" name="amount" size="10">
<br />
<br />
Wpisz maksymalną wartość liczby: <input type="text" name="max" size="10">
<br />
<br />
Wpisz minimalną wartość liczby: <input type="text" name="min" size="10">
<br />
<br />
<input type="submit" name="submit" value="Generuj!">
</form>
<br />
<br />
<br />
To narzędzie zostało stworzone przez: <a href="link">.....</a>
<br />
<?php
}
else
{
//form submitted, grab the data from POST
$amount =trim($_POST['amount']);
$max =trim($_POST['max']);
$min =trim($_POST['min']);
//test if it contains some data.
if (((isset($amount)) && !(trim($amount) == "") && !(trim($max) == "") && !(trim($min) == "")) && ((is_numeric($amount)) && (is_numeric($max)) && (is_numeric($min)) && ($max > $min)))
{
//form input is either not empty and is numeric, process values
echo '<h2>Below are the generated decimal random numbers:</h2><br /><br />';

$i = 1;
while ($i <= $amount) {
$random =mt_rand($min,$max);
$i++;
echo $random;
echo '<br />';
}
echo '<br />';
echo '<br />';
echo 'You have set max value to: &nbsp;'.$max;
echo '<br />';
echo 'You have set min value to: &nbsp;'.$min;
echo '<br />';
echo 'Amount of random numbers generated: &nbsp;'.$amount;
echo '<br />';
echo '<br />';
echo '<a href="/decimalrandomnumbergenerator.php">Try again this tool</a><br />';
}
else
{
//something is wrong with the inputted data
echo 'Please double check inputted data, it seems you either enter a blank data, wrong captcha, inputted a non-numeric value or inputted a value in a maximum field but is actually a minimum than your minimum set value.';
echo '<br />';
echo '<a href="/decimalrandomnumbergenerator.php">Click here to input data again.</a>';
}
}
?>


#7 mozor

    Zaawansowany

  • Autor tematu
  • Użytkownik

Reputacja: 1
Nowy

  • Postów:105
Offline

Napisano 06.08.2012 20:32

Wielkie dzięki ;]

A mógł byś mi podpowiedzieć jak zrobić żeby te liczby na jakimś tle graficznym się pokazywało?
  • +
  • -
  • 0

#8 ELOS

    No i pozamiatane ;*

  • Power User

Reputacja: 145
Zaawansowany

  • Postów:703
  • GG:
  • Imię:Kamil
  • Lokalizacja:Będzin
Offline

Napisano 10.08.2012 22:51

dodaj backgrounda i ustaw mu divem pozycje.
  • +
  • -
  • 0

[Aktualizacja 22.01.2015] GunXpMod 2.7.4

http://wklej.to/vlMW7


#9 speedkill

    Godlike

  • Przyjaciel

Reputacja: 1 592
Godlike

  • Postów:2 733
  • GG:
  • Steam:steam
  • Imię:Michał
  • Lokalizacja:Prudnik
Offline

Napisano 11.08.2012 10:46

http://php.net/manua.../book.image.php
  • +
  • -
  • 0

If you can dream it, you can do it.






Również z jednym lub większą ilością słów kluczowych: php

Użytkownicy przeglądający ten temat: 0

0 użytkowników, 0 gości, 0 anonimowych