What is wrong with this php code ? .
(it works fine - but something that just works isnt good enough for this
newsgroup is it)
<?php
$loopy=1; $kon="repo"; $spock=0;
while ($kon=="repo")
{
$khan=(rand()%$ chekov); $khan=$khan+1;
if ($kirk[$khan]=="") {$spock=$spock+ 1; $kirk[$spock]=$khan;}
if ($spock>55) {break;}
if ($loopy>222) {$kon="break";}
$loopy=$loopy+1 ;
}
sort($kirk); $kirk=array_key s(array_flip($k irk));
$loopy=0;
while ($loopy<5)
{
$bones=$kirk[$loopy];
if ($bones<>"") {include('displ ay_entry.php'); }
$loopy=$loopy+1 ;
}
?> 36 3826
On Aug 6, 8:08*pm, Krustov <m...@privacy.n etwrote:
What is wrong with this php code ? .
(it works fine - but something that just works isnt good enough for this
newsgroup is it)
<?php
$loopy=1; $kon="repo"; $spock=0;
while ($kon=="repo")
{
$khan=(rand()%$ chekov); $khan=$khan+1;
if ($kirk[$khan]=="") {$spock=$spock+ 1; $kirk[$spock]=$khan;}
if ($spock>55) {break;}
if ($loopy>222) {$kon="break";}
$loopy=$loopy+1 ;
}
sort($kirk); $kirk=array_key s(array_flip($k irk));
$loopy=0;
while ($loopy<5)
{
$bones=$kirk[$loopy];
if ($bones<>"") {include('displ ay_entry.php'); }
$loopy=$loopy+1 ;
}
?>
Troll, go away.
On Wed, 6 Aug 2008 19:08:40 +0100, Krustov <me@privacy.net wrote:
>What is wrong with this php code ? .
(it works fine - but something that just works isnt good enough for this newsgroup is it) <?php
$loopy=1; $kon="repo"; $spock=0;
while ($kon=="repo") { $khan=(rand()% $chekov); $khan=$khan+1; if ($kirk[$khan]=="") {$spock=$spock+ 1; $kirk[$spock]=$khan;} if ($spock>55) {break;} if ($loopy>222) {$kon="break";} $loopy=$loopy+ 1; }
sort($kirk); $kirk=array_key s(array_flip($k irk));
$loopy=0; while ($loopy<5) { $bones=$kirk[$loopy]; if ($bones<>"") {include('displ ay_entry.php'); } $loopy=$loopy+ 1; }
?>
Krusty, one day soon your code will be used by all the great teaching
establishments of the world. Here is example code to take the breath
away. Clarity, beauty, functionality, conciseness - out the window
with you! Here are perfect examples of how not to write code.
Never in the field of computer programming has so much crap been
written by so few.
P.S. if you wrote your code properly you would see the problem on the
6th line after <?php.
--
Regards, Paul Herber, Sandrila Ltd. http://www.sandrila.co.uk/ http://www.pherber.com/
Message-ID: <MP************ ************@ne ws.newsreader.c omfrom
Krustov contained the following:
>What is wrong with this php code ? .
(it works fine - but something that just works isnt good enough for this newsgroup is it)
Why don't you just tell us what it's supposed to do? If you just need
five random numbers from a range you've got waaay too much code.
--
Geoff Berrow 011000100110110 0010000000110
001101101011011 001000110111101 100111001011
100110001101101 111001011100111 010101101011 http://slipperyhill.co.uk
<comp.lang.ph p>
<Geoff Berrow>
<Wed, 06 Aug 2008 22:45:24 +0100>
<vn************ *************** *****@4ax.com>
What is wrong with this php code ? .
(it works fine - but something that just works isnt good enough for this
newsgroup is it)
Why don't you just tell us what it's supposed to do? If you just need
five random numbers from a range you've got waaay too much code. www.jpgimage.co.uk/full.php?image=1232 www.jpgimage.co.uk/full.php?image=1233
I needed something to fill up the guestbook.php page and displaying some
random guestbook entrys was the quick fix solution i came up with .
As the (latest entrys) button is right next to it - obviously its best
to display the oldest of the 5 random entrys first .
Can you post 1 or 2 lines of 'magic wand' code to do the same job ? .
On Aug 7, 12:18*am, Krustov <m...@privacy.n etwrote:
<comp.lang.ph p>
<Geoff Berrow>
<Wed, 06 Aug 2008 22:45:24 +0100>
<vn6k94hhfh1k9i h7kjfv8dndeql1s oo...@4ax.com>
>What is wrong with this php code ? .
>(it works fine - but something that just works isnt good enough for this
>newsgroup is it)
Why don't you just tell us what it's supposed to do? *If you just need
five random numbers from a range you've got waaay too much code.
http://www.jpgimage.co.uk/full.php?i...php?image=1233
I needed something to fill up the guestbook.php page and displaying some
random guestbook entrys was the quick fix solution i came up with .
As the (latest entrys) button is right next to it - obviously its best
to display the oldest of the 5 random entrys first .
Can you post 1 or 2 lines of 'magic wand' code to do the same job ? .
if you have $n entries, how about doing something like
<?php
$indices = range(0, $n-1);
shuffle($indice s);
$indices = array_splice($i ndices, 5);
rsort($indices) ;
?>
Granted, it isn't fast, but it's easy to read/maintain and the speed
difference will be negligible if $n isn't very high.
Sorry about my earlier post, I thought you were making a joke.
-egbert
<comp.lang.ph p>
<Egbert Teeselink>
<Wed, 6 Aug 2008 15:26:08 -0700 (PDT)>
<0a************ *************** *******@34g2000 hsh.googlegroup s.com>
if you have $n entries, how about doing something like
<?php
$indices = range(0, $n-1);
shuffle($indice s);
$indices = array_splice($i ndices, 5);
rsort($indices) ;
?>
Granted, it isn't fast, but it's easy to read/maintain and the speed
difference will be negligible if $n isn't very high.
What about the code used to display the 5 random entrys .
Message-ID: <MP************ ************@ne ws.newsreader.c omfrom
Krustov contained the following:
>Can you post 1 or 2 lines of 'magic wand' code to do the same job ? .
Yep.
Let's say you have entries numbered from 0 to $n
$rand_entries = array_rand(rang e(0, $n), 5);
//$rand_entries is now an array containing 5 random numbers between 0
and $n
--
Geoff Berrow 011000100110110 0010000000110
001101101011011 001000110111101 100111001011
100110001101101 111001011100111 010101101011 http://slipperyhill.co.uk
Message-ID: <ck************ *************** *****@4ax.comfr om Geoff
Berrow contained the following:
>Let's say you have entries numbered from 0 to $n
$rand_entrie s = array_rand(rang e(0, $n), 5); //$rand_entries is now an array containing 5 random numbers between 0 and $n
Hey look - a UK lottery ball picker!
asort($ar=array _rand(range(1, 49), 6));
echo implode(", ", $ar);
--
Geoff Berrow 011000100110110 0010000000110
001101101011011 001000110111101 100111001011
100110001101101 111001011100111 010101101011 http://slipperyhill.co.uk
Message-ID: <MP************ ************@ne ws.newsreader.c omfrom
Krustov contained the following:
> That must be where the magic wand comes in eh! :-)
Looking at it again, if $bones is the variable to get the entry
$rand_entries = array_rand(rang e(0, $n), 5);
foreach($rand_e ntries as $bones){
include('displa y_entry.php');
}
--
Geoff Berrow 011000100110110 0010000000110
001101101011011 001000110111101 100111001011
100110001101101 111001011100111 010101101011 http://slipperyhill.co.uk This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Jules |
last post by:
I've searched high and low for a 3 digit number generator that will
pick at random a number between 000 and 999.
The only things I have found were generators that pick numbers from 0
to 999.
I want one that if the number picked is 0 through 99 it is generated
as 000 through 099.
Can anyone help me with this? Cause I'm stumpt.
|
by: Virus |
last post by:
Ok well what I am trying to do is have
1.) the background color to change randomly with 5 different colors.(change
on page load)
2,) 10 different quotes randomly fadeing in and out in random spots on the
webpage. with a delay timer on them, so they keep changing as the page is
open. Not random each time the page is loaded.
If anyone can help it would be greatly appreaciated, I have tried many of
|
by: Ini |
last post by:
Hi,
Is there an easy way to pick at random one record out of a recordset and
then leave this recordset?
I was thinking about doing a recordcount of the recordset, then find at
random the number between 1 and <recordcount> and then move to this record
in the recordset.
There is a easier way, isn't it?
|
by: Paul Tomlinson |
last post by:
How can I randomly pick either the value integer 5 or integer 8??
I don't want a value between 5 and 8 but either the values 5 or 8 randomly.
Any ideas on how can I do this please??
MA
|
by: Sven |
last post by:
How much entrys can a listbox handle without crashing?
| |
by: TCORDON |
last post by:
How can i tell VB.NET to pick a random number from a predefined series like:
10,10,10,38,38,17,17,17,17,92
TIA
|
by: JJ |
last post by:
Hi,
I created the sample web service that comes when you use template in VS
2003. Had no problems compiling the web service but when I go to client app
and select web ref I get multiple entrys for same web service when using the
discovery under localhost. What could cause this? This is first web service
on this machine.
Thanks,
|
by: Mike Langworthy |
last post by:
i can not seem to get this code to work. someone please help
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
|
by: rhen18 |
last post by:
Good day!
Im working on a math drill program where the user is asked to answer random math problems that involves the +, -, /, *, and % operators.
Now i dont know how to generate these randomly.
What commands and codes could I use?
So much thanks in advance!
Have a fruitful new year!
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |