Jump to content

showme48

New Members
  • Posts

    5
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

showme48's Achievements

Newbie

Newbie (1/5)

1

Reputation

  1. Hello, I have a function to get a users rank in a contest and need some help on sorting it by a different means. Right now it take entries*referrals and then sorts based upon that but I want to be able to sort multiple ways. Right now if the user has no referrals they are not included in the sorting process and I can't get my mind wrapped around how to include all of them. For example it should work like this user1 5 entries 2 referrals for a total of 10 user2 0 entries 0 referrals for a total of 0 user3 3 entries 1 referrals for a total of 3 user4 0 entries 0 referrals for a total of 0 user5 100 entries 0 referrals for a total of 100 In my mind user5 should rank #1 as the total is 100 user1 should be 2nd as total is 10 user3 should be third as total is 3 user2 would be 4th as total is zero then (based upon id) user4would be 5th as total is zero then (based upon id) But what it does is this user1 is ranked 1st user3 is ranked 2nd user2 and user4 and user5 are left out because they have no referrals any help would be greatly appreciated. here is the code function get_user_rank($usrid,$contest_start,$type) { $conteststart = date('Y-m-d', strtotime(date('Y-1-1'))); $res = mysql_query("SELECT m1.referid, m2.name, m2.lastname, m2.userid, m2.".$type." as entries, count(*) as referrals FROM members m1 inner join members m2 on m1.referid=m2.userid where m2.verified=1 and m1.verified=1 and m1.joindate > '".$contest_start."' group by m1.referid, m2.name ORDER BY entries DESC"); while ( $r = mysql_fetch_assoc($res) ) { $mdata[$r['userid']]['userid'] = $r['userid']; $mdata[$r['userid']]['total_entries'] = $r['entries'] * $r['referrals']; } usort($mdata, 'sort_leaders'); for ( $i=0; $i < count($mdata); $i++ ) { if ( $mdata[$i]['userid'] == $usrid ) return $i+1; next($mdata); } return 0; } function sort_leaders($a, $b) { if ( $a['total_entries'] == $b['total_entries'] ) return 0; return ( $a['total_entries'] > $b['total_entries'] ) ? -1 : 1; } $year_start = date('Y-m-d', strtotime(date('Y-1-1'))); get_user_rank($userid,$year_start,"contesty");
  2. Hello, I'm trying to post data to some remote sites and I think I have something in the wrong order. Any help would be appreciated. Thanks for your time. Here is how its suppose to work... gets array of siteurl from sites gets the id of the ads being posted (multiple ids) selects the ad from received checks to see if the url from the ad (received) is the same as one of the siteurl in the array if it is the same then $url2 should equal $info ['url'] if it is not then $url2 should equal 'http://'.$row['siteurl'].'/ads.php?id='.$info ['id'].''; Basically it checks to see which site the original ad was posted from and then when it post back to that site it post the original url, if it post to a different site then it post a different url. Right now it post these results Ad 1 Site 1 http://siteone.com/ads.php?pageid=clickadd&id=1 Site 2 http://sitetwo.com/ads.php?pageid=clickadd&id=1 Site 3 http://sitethree.com/ads.php?pageid=clickadd&id=1 Ad 2 Site 1 http://siteone.com/ads.php?pageid=clickadd&id=2 Site 2 http://sitetwo.com/ads.php?pageid=clickadd&id=2 Site 3 http://sitethree.com/ads.php?pageid=clickadd&id=2 and it should post something like Ad 1 Site 1 http://siteone.com/ads.php?pageid=clickadd&id=1 Site 2 http://someurl.com // because the ad #1 originally came from site #2 Site 3 http://sitethree.com/ads.php?pageid=clickadd&id=1 Ad 2 Site 1 http://siteone.com/ads.php?pageid=clickadd&id=2 Site 2 http://sitetwo.com/ads.php?pageid=clickadd&id=2 Site 3 http://someotherurl.com // because the ad #2 originally came from site #3 foreach($id as $each) { $sql = mysql_query ( "SELECT * FROM receive WHERE id=" . $each ); $info = mysql_fetch_array ( $sql ); // Work out partial data , excluding url for checking and updating ... $wannasay = array ( "id" => $info ['id'], "site" => $info ['site']; // Generate Query string $dataels = array (); foreach ( array_keys ( $wannasay ) as $thiskey ) { array_push ( $dataels, urlencode ( $thiskey ) . "=" . urlencode ( $wannasay [$thiskey] ) ); } $data = implode ( "&", $dataels ); $result = mysql_query("SELECT siteurl FROM sites"); $nodes = array(); $i=0; while ( $row = mysql_fetch_assoc($result) ) { $nodes[] = 'http://'.$row['siteurl'].'/admin/curl.php'; $nodes2[$i] = $row['siteurl']; $i++; // Here is where I have problems foreach( $nodes2 as $value ) { if($value == $info ['site']) { $url2 = $info ['url']; } else $url2 = 'http://'.$row['siteurl'].'/ads.php?id='.$info ['id'].''; } $postfields = $data.'&url=' . $url2; // Update Full query string .. $node_count = count($nodes); $curl_arr = array(); $master = curl_multi_init(); for($i = 0; $i < $node_count; $i++) { $url =$nodes[$i]; $curl_arr[$i] = curl_init($url); curl_setopt($curl_arr[$i], CURLOPT_POST, 1); curl_setopt($curl_arr[$i], CURLOPT_POSTFIELDS, $postfields); curl_setopt($curl_arr[$i], CURLOPT_RETURNTRANSFER, 1); curl_multi_add_handle($master, $curl_arr[$i]); } do { curl_multi_exec($master,$running); } while($running > 0); for($i = 0; $i < $node_count; $i++) { $results = curl_multi_getcontent ( $curl_arr[$i] ); echo( "\n" . $results . "\n"); } } }
  3. Thanks kicken, That worked perfectly. Sent you a tip... Donation Sent (Unique Transaction ID #5GY846557U109843P)
  4. Thanks jazzman1, I tried that and it did not work. I appreciate the effort but it has been solved.
  5. Hello, I'm trying to unserialize a string and then compare it and if listed mark the checkbox as CHECKED. It works fine as long as I have 1,2,3,4 checked but if I do something like 1,4 then it only shows 1 as being CHECKED Any help would be appreciated. Thanks in advance. function getm($id) { $query3 = "select memtype from offer WHERE id = '".$id."'"; $result3 = mysql_query ($query3) or die ("Query failed"); $line3 = mysql_fetch_array($result3); $memtype = $line3["memtype"]; $mydata = unserialize($memtype); echo '<tr bgcolor=#CCCCCC><td>'; echo 'Show to:</td><td>'; if(!empty($mydata)) { foreach( $mydata as $key => $value) { $gamenames[] = $key; } } $getaccountinfo = mysql_query("Select id, mem_name, mem_rank from `memtype` WHERE mem_enabled=1 ORDER BY id ASC"); for ($j = 0; $j < mysql_num_rows($getaccountinfo); $j++) { $offerid = mysql_result($getaccountinfo, $j, "id"); $memname = mysql_result($getaccountinfo, $j, "mem_name"); echo(" $gamenames[$j] <input type=checkbox name=memtype[$offerid] value=$offerid"); if($gamenames[$j]==$offerid){echo(" CHECKED");} echo(">$memname <br>"); } echo '</td></tr>'; } $sql = mysql_query("SELECT * FROM offer"); echo '<table border=0><tr><td>'; while($oto = mysql_fetch_array($sql)) { if($count==1) { echo "</td><td>"; $count=0; } $count++; ?> <h3 align=center>OFFER <?php echo $oto['id']; ?></h3> <form method="POST"> <input type="hidden" name="action" value="updateoffer"> <input type="hidden" name="id" value="<?php echo $oto['id']; ?>"> <table border=0 cellpadding=5 bgcolor=#000000> <tr bgcolor=#CCCCCC><td>Price:</td><td>$<input type="text" name="price" value="<?php echo $oto['price']; ?>"></td></tr> <tr bgcolor=#CCCCCC><td>Commission:</td><td>$<input type="text" name="pdcommission" value="<?php echo $oto['pdcommission']; ?>"></td></tr> <tr bgcolor=#CCCCCC><td>Show after login:</td><td><input type="radio" name="enable" value="1"<?php if($oto['enable'] == 1) echo " CHECKED"; ?>> yes <input type="radio" name="enable" value="0"<?php if($oto['enable'] == 0) echo " CHECKED"; ?>> no</td></tr> <?php $showm=getm($oto['id']); ?> <tr><td colspan="2" align="center"><input type="submit" value="Update"></td></tr> </table> </form> <?php } echo '</td></tr></table>'; ?>
×
×
  • 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.