Jump to content

Nexus10

Members
  • Posts

    53
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Nexus10's Achievements

Member

Member (2/5)

0

Reputation

  1. No, I have a variable $industry which holds the value 'textiles' (but it also holds 20 other values as well at different times).
  2. $industry = "Textiles"; $a = ${$industry}; echo("<br />a: $a"); $a is then blank. ?
  3. I'm still confused by that.
  4. <?php $learn_textiles_lvl = 5; // original variable $a = "$"."learn_".$industry."_lvl"; // attempt at reconstructing original variable when only $industry is known (it is not always 'textiles') $current_level = $a; // test echo("<br />Current level: $current_level"); ?> How do I construct a variable and get its contents (existing) from a string function (or other way)? I.e. I have the varible $industry and need to get the contents of an existing variable called $learn_(INDUSTRY)_lvl where INDUSTRY is defined in the variable $industry.
  5. Well the above (not the raffle script) does what I need and I've already got 90% of it (just need to get that winner selecting right now) so I'd rather get my code above working.
  6. I still can't get it working
  7. Anyone?
  8. Okay, so this is what I've got (doesn't work): $query = "SELECT * FROM lottery_current"; $result = mysql_query($query) or die("Error: Could not be completed. <br>" . mysql_error()); $count = mysql_num_rows($result); while($row = mysql_fetch_array($result)){ echo $row['user_name']; echo $row['numTickets']; $numTicketsTotal = $numTicketsTotal + $row['numTickets']; } echo("<p>numTickets: $numTicketsTotal"); $prize = (10000 + (0.90 * 1500 * $numTicketsTotal)); echo("<p>Prize: $prize"); $result = mysql_query("SELECT * FROM lottery_current"); while($row = mysql_fetch_array($result)){ $user_name = $row['user_name']; $numTickets = $row['numTickets']; echo("<p>User name: $user_name"); echo("<p>No. of tickets: $numTickets"); $data = array($user_name => $numTickets); } $pot = array(); foreach($data as $user_name => $numTickets) { $pot = array_merge($pot, array_fill(0, $numTickets, $user_name)); } echo("<p>"); print_r($pot); //echo("<p>"); //print_r($data); shuffle($pot); echo("<p>"); echo $pot[0]; echo("<p>Done"); Which produces pillow1admin2terry1obama2 numTickets: 6 Prize: 18100 User name: pillow No. of tickets: 1 User name: admin No. of tickets: 2 User name: terry No. of tickets: 1 User name: obama No. of tickets: 2 Array ( [0] => obama [1] => obama ) obama Done The problem is, only the last user/purchaser of tickets seems to be in the array (i..e user 'obama' always wins here, no one else ever does). Can anyone see why?
  9. ?
  10. Thanks, although I don't really understand it fully. Is there simpler way to do this (even if its slightly longer/less elegant)?
  11. My webhost has error reporting disabled/off (and won't enable it). Needless to say I won't be renewing with them once my current hosting expires.
  12. I need to draw a lottery somehow although am getting lost. My database has a table which has two columns: 'user' and 'numTickets' where user is there user name nad numTickets is hte number of tickets they had. I.e. the table may look like (only player's with tickets will have an entry): Player1 12 Player 2 1 Player 3 43 Player 4 7 I am having trouble manipulating this data to provide 12 tickets to Player 1, 1 ticket to Player 2 etc so we can calculate a winner etc by using the random function (to get a random number from 1 to 63 in this case here). Any suggestions (preferably with a brief sample)?
  13. $to = $email; $subject = "Account Verification"; $header = "from: NexusIndustry <[email protected]>"; $message = "Your confirmation link: \r\n"; $message .= "Click on this link (or copy and paste into the address bar) to activate your account \r\n"; $message .= "http://www.nexusindustry.com/admin/confirm.php?passkey=$email_auth"; $sentmail = mail($to, $subject, $message, $header);
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.