Jump to content

poe

Members
  • Posts

    143
  • Joined

  • Last visited

    Never

Everything posted by poe

  1. still cant get it to work, if i go: [code] $string = " <input type=\"radio\" name=\"0SelectedOdds2\" value=\"4.5\" onclick=\"updatePayout(this,'1057','2006-11-19 00:00:00.0','Sunday, November 19, 2006','22','10:00PM','HKY','CHI','VAN','V+','0','You can only pick a maximum of 6 odds','')\"> "; preg_match_all('/(?<=name=").*?(?=")|(?<=value=").*?(?=")|(?<=,\').*?(?=\')/', $string, $matches); list( $name, $value, $card, $gtmdate, $longdate, $gameid, $gametime, $sport, $visitor, $home, $radioid, $radiofield, $rules, $tbafield ) = $matches[0]; print_r($matches) [/code] i get: Array ( [0] => Array ( ) )
  2. i have a series of radio buttons lik so: <input type="radio" name="0SelectedOdds2" value="4.5" onclick="updatePayout(this,'1057','2006-11-19 00:00:00.0','Sunday, November 19, 2006','22','10:00PM','HKY','CHI','VAN','V+','0','You can only pick a maximum of 6 odds','')"> i want to loop through each button and extract all the parts into different vars so far i have: preg_match_all("/<input type=(\"|\')?radio[^>]*>/", $html, $match_radio, PREG_SET_ORDER); but that only extrracts the radio buttons from the page. how do i get all the different parts within the radiobutton. the result i want is: $name = '0SelectedOdds2' $value = '4.5' $card = '1057' $gtmdate = '2006-11-19 00:00:00.0' $longdate = 'Sunday, November 19, 2006' $gameid = '22' $gametime = '10:00PM' $sport = 'HKY' $visitor = 'CHI' $home = 'VAN' $radioid = 'V+' $radiofield = '0' $rules = 'You can only pick a maximum of 6 odds' $tbafield = ''
  3. poe

    sort results

    i get this error mysql_query() failed: Every derived table must have its own alias
  4. poe

    sort results

    i want to sort a column and show the 4 largest numbers from smallest to largest. i know if i " ORDER BY col DESC LIMIT 4 " that will get me the highest 4 numbers. but i now want to sort these numbers from small to large random order: 38 : 22 : 19 : 45 : 15 : 02 : 78 ORDER BY col DESC LIMIT 4: 78 : 45 : 38 : 22  [excluded 19, 15, 02] i want to show: 22 : 38 : 45 : 78 if i make another 'ORDER BY' it gives me an error
  5. team opp wlt gf ga ----------------------------------------- tor    mtl    w 5      1 tor phi    w 4 1 tor atl    w 4 2 tor ott l 2 6 tor nyr so 4 5 tor col l 1 4 tor cgy w 5 4 tor fla w 2 1 tor mtl so 2 3 tor ott l 1 4 the result i want is: team games wins loss tie ttlgf ttlga    - ...note (so=tie) tor 10 5 3 2 30 31 the query i have is : query = SELECT team, count(team), count(wlt), sum(gf), sum(ga) FROM games WHERE team='tor' basically: get the team games = count the rows wins = count 'w' loss = count 'l' tie = count 'so' ttlgf & ttlga = sum() thanks
  6. might not be the answer you were looking for, but you could just use: http://hockey.fantasysports.yahoo.com/hockey/ or another good place where you can download stats is: http://www.sportsinteractive.com/Stats.asp i think they also let you set up pools there too. and there is no programming involved
  7. ok this is my full code:, just a shrotened version of what i have now. [code] <?php $mystring = "[name][age][pet][mike][22][dog][john][25][cat][kim][26][bird][pam][18][fish]"; $mystring = replace("][",",",$mystring); $mystring = replace("[","",$mystring); $mystring = replace("]","",$mystring); $myarray  = explode(",",$mystring); for ($i=3; $i<count($myarray); $i+=3) {     $people[] = array(         $myarray[0] => $myarray[$i+0],         $myarray[1] => $myarray[$i+1],         $myarray[2] => $myarray[$i+2]     ); } ?> [/code] this is the array it produces: [quote] Array (     [0] => Array (             [name] => mike             [age] => 22             [pet] => dog )     [1] => Array (             [name] => john             [age] => 25             [pet] => cat )     [2] => Array (             [name] => kim             [age] => 26             [pet] => bird )     [3] => Array (             [name] => pam             [age] => 18             [pet] => fish ) ) [/quote] what i want to do is: lets say my array has 18 keys i dont want to repeat typing out  ** $myarray[0] => $myarray[$i+0] **etc... - 18 times or whatever i was planning on making this into a little function that would split any string into an array the same way. but each string would have different number of keys. i also want to keep my key names & values intact. i was looking for a shortcut that i could go: for($x=1; $x<18; $x++) $myarray[$x] => $myarray[$i+$x]; ...or something when i refer back to the array i want to use : $key[2]['name']
  8. i have this bit of code that someone replied to an earlier post: [code] for ($i=7; $i<count($myarray); $i+=7) {     $people[] = array(         $myarray[0] => $myarray[$i+0],         $myarray[1] => $myarray[$i+1],         $myarray[2] => $myarray[$i+2],         $myarray[3] => $myarray[$i+3],         $myarray[4] => $myarray[$i+4],         $myarray[5] => $myarray[$i+5],         $myarray[6] => $myarray[$i+6]     ); [/code] is there a way to build the array dynamiclly without hard coding the array incriments ie.. for ($i=7; $i<count($myarray); $i+=7) {     $people[] = array(         for ($x=0; $x<7; $x++) {               $myarray[$x] => $myarray[$i+$x],         }     ); }
  9. lets say i have: function makeName($fullNameString) {   list($fn, $mn, $ln) = split(":", $fullNameString);   $nameArray[] = array($fn, $mn, $ln, ); }// end function i want my array to eventually looks like this:   $nameArray[] = array('chris', 'w', 'smith', );   $nameArray[] = array('pam', 't', 'lee', );   $nameArray[] = array('mary', 'g', 'smith', );   $nameArray[] = array('kim', 'a', 'jones', ); how do i access the "nameArray" later on such as: foreach($nameArray as $k => $v){ echo "hello ".$v[0]; } since the 'namearray' was created inside a function i cant get it to show results.
  10. poe

    PHP Array Help

    <select> <option value ="positive">Positive</option> <option value ="negative">Negative</option> <option value ="genuine" selected="selected">Genuine Contact</option> <option value ="twaste">Time Wasters</option> </select> try: [code] $ary = array(   "positive"=>"Positive",   "negative"=>"Negative",   "genuine"=>"Genuine Contact",   "twaste"=>"Time Wasters", ); echo "<select>\n"; foreach($ary as $k => $v) {   echo "<option value=".$k.">".$v."</option>\n"; } echo "</select>\n"; [/code]
  11. i will have a string that is for sports scores and is shown  as: outcome(w,l,t,so,nd) team score : opp score so it would look like: [a-z] [0-9] : [0-9] ie. w14:3 OR l16:21 OR so4:3 OR t6:6 etc... i want to add a `:` after the outcome ie..  w:7:3 how do i add a : after the alpha charactert(s)
  12. i have a string like this: [pre] $mystring = "[name][age][pet][mike][22][dog][john][25][cat][kim][26][bird][pam][18][fish]"; [/pre] each item is surrounded by [] i want to strip the [] and create into an array with the first 3 as the keys, then every other third grouping the values. ie $people[1] = array( 'name'=>'mike', 'age'=>'22', 'pet'=>'dog'); $people[2] = array( 'name'=>'john', 'age'=>'25', 'pet'=>'cat'); $people[3] = array( 'name'=>'kim', 'age'=>'26', 'pet'=>'bird'); $people[4] = array( 'name'=>'pam', 'age'=>'18', 'pet'=>'fish'); EDIT: OK. I think it's solved now! :)
  13. update. i read some other posts and i think i figured it out. $query .= " SELECT links.url, id_link, COUNT(*) AS cnt "; $query .= " FROM clicks "; $query .= " INNER JOIN links ON clicks.id_link = links.id "; $query .= " GROUP BY id_link "; $query .= " ORDER BY cnt ASC "; $query .= " LIMIT 5 ";
  14. i have 2 tables links (3 fields) - id - | - name - | - url - 1 | msn | www.msn.com 2 | google web page | www.google.com 3 | cnn news | www.cnn.com 4 | yahoo home page | www.yahoo.com etc... clicks (2 fields) - id - | - link_id - 1 | 2 2 | 4 3 | 4 4 | 1 5 | 3 6 | 3 7 | 4 etc... as someone clicks a link, the link _id is recorded in my clicks table. i now want to show the results by most popular link to least. ie. - rank - | - id - | - count - | - url - | - name - 1 | 4 | 73 | www.yahoo.com |  yahoo home page 2 | 3 | 24 | www.cnn.com | cnn news 3 | 2 | 18 | www.google.com | google web page .... etc.... $query = " SELECT link_id, COUNT(link_id) AS id_count FROM clicks GROUP BY link_id ORDER BY id_count DESC "; this will give me ... - rank - | - id - | - count - 1 | 4 | 73 2 | 3 | 24 3 | 2 | 18 .... etc.... but, how do i get my results to include the data from links table (url, name) $query = " SELECT clicks.link_id, COUNT(clicks.link_id) AS id_count, links.url, links.name FROM clicks, links GROUP BY link_id ORDER BY id_count DESC "; if i use this query, my count is way off as if it takes the count multiplied by number of records in the links table
  15. i have 2 tables links (3 fields) - id - | - name - | - url - 1 | msn | www.msn.com 2 | google web page | www.google.com 3 | cnn news | www.cnn.com 4 | yahoo home page | www.yahoo.com etc... clicks (2 fields) - id - | - link_id - 1 | 2 2 | 4 3 | 4 4 | 1 5 | 3 6 | 3 7 | 4 etc... as someone clicks a link, the link _id is recorded in my clicks table. i now want to show the results by most popular link to least. ie. - rank - | - id - | - count - | - url - | - name - 1 | 4 | 73 | www.yahoo.com |  yahoo home page 2 | 3 | 24 | www.cnn.com | cnn news 3 | 2 | 18 | www.google.com | google web page .... etc.... $query = " SELECT link_id, COUNT(link_id) AS id_count FROM clicks GROUP BY link_id ORDER BY id_count DESC "; this will give me ... - rank - | - id - | - count - 1 | 4 | 73 2 | 3 | 24 3 | 2 | 18 .... etc.... but, how do i get my results to include the data from links table (url, name) $query = " SELECT clicks.link_id, COUNT(clicks.link_id) AS id_count, links.url, links.name FROM clicks, links GROUP BY link_id ORDER BY id_count DESC "; if i use this query, my count is way off as if it takes the count multiplied by number of records in the links 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.