Lamez Posted February 11, 2008 Share Posted February 11, 2008 Alright I have a NCAA bracket, and it deals with java, I did find this off the internet, but I have looked, and looked over the code, and I cannot find out where it inserts the picks into a DB. Could you guys help me out and tell me how to process the variables so I could add it to a DB with PHP <script language="JavaScript" type="text/JavaScript"> // Initialize the bracket function Initialize_Bracket() { document.Web_Entry.reset(); advanceToTheResults(); } // This function adances the team the user has selected. function Chose_Tm(choseID, teamID) {var id="entry"+choseID; var currpick = pick[choseID]; // 0 is default if (choseID > 32){ // Second round pick or higher teamID = pick[teamID]; if (teamID == 0) {return;} //teamID++; } else if (playinGame && teamID==playinID && choseID==nextgame[0]) { teamID = pick[teamID-playinID]; if (teamID == 0) {return;} } if (currpick == teamID){return;}; // was -1 var text=team[teamID]; //alert(text+" ChoseID:"+pick[choseID]); pick[choseID] = teamID; // was -1 //if (choseID==30) //alert(text+" pick["+choseID+"]="+pick[choseID]); Print_Tm(id, text); var nextround = choseID; while (nextround != 63){ var nextroundpick = pick[nextgame[nextround]]; if (nextroundpick != 0){ if (nextroundpick == currpick){ if (nextroundpick != teamID){ // was -1 pick[nextgame[nextround]] = teamID; // was -1 Print_Tm("entry"+nextgame[nextround],text); } } } nextround = nextgame[nextround];} } // This function will write some stuff ... may need to re-write this. function Print_Tm(id, text) {if (document.layers){ var l = document[id]; if (!l.ol) { var ol = l.ol = new Layer (l.clip.width, l); ol.clip.width = l.clip.width; ol.clip.height = l.clip.height; ol.bgColor = l.bgColor; l.visibility = 'hide'; ol.visibility = 'show';} var ol = l.ol; out = " "; add = " "; teamtext = "" + text; while (teamtext.indexOf(out)>-1){ pos= teamtext.indexOf(out); teamtext = "" + (teamtext.substring(0, pos) + add + teamtext.substring((pos + out.length), teamtext.length));} ol.document.open(); ol.document.write('<span class="bk_clr2">'+teamtext+'</span>'); ol.document.close(); ol.clip.width=l.clip.width=ol.document.width; ol.clip.height=l.clip.height=ol.document.height;} else if (document.all || document.getElementById) { if (document.all) document.all[id].innerText = text; else { var l = document.getElementById(id); var r = document.createRange(); r.setStartAfter(l); var docFrag = r.createContextualFragment(text); while (l.hasChildNodes()) l.removeChild(l.firstChild); l.appendChild(docFrag);} } } var spacer=' '; if(document.layers){ for(counter=2; counter <= 15; counter++) {spacer=spacer+' '} origWidth=innerWidth; origHeight=innerHeight; onresize=function(){ if(innerWidth!=origWidth||innerHeight!=origHeight) location.reload()} } var playinGame=false; var playinID=50; var nextgame = new Array(62); nextgame[0] = playinID/2; nextgame[1] = nextgame[2] = 33; nextgame[3] = nextgame[4] = 34; nextgame[5] = nextgame[6] = 35; nextgame[7] = nextgame[8] = 36; nextgame[9] = nextgame[10] = 37; nextgame[11] = nextgame[12] = 38; nextgame[13] = nextgame[14] = 39; nextgame[15] = nextgame[16] = 40; nextgame[17] = nextgame[18] = 41; nextgame[19] = nextgame[20] = 42; nextgame[21] = nextgame[22] = 43; nextgame[23] = nextgame[24] = 44; nextgame[25] = nextgame[26] = 45; nextgame[27] = nextgame[28] = 46; nextgame[29] = nextgame[30] = 47; nextgame[31] = nextgame[32] = 48; nextgame[33] = nextgame[34] = 49; nextgame[35] = nextgame[36] = 50; nextgame[37] = nextgame[38] = 51; nextgame[39] = nextgame[40] = 52; nextgame[41] = nextgame[42] = 53; nextgame[43] = nextgame[44] = 54; nextgame[45] = nextgame[46] = 55; nextgame[47] = nextgame[48] = 56; nextgame[49] = nextgame[50] = 57; nextgame[51] = nextgame[52] = 58; nextgame[53] = nextgame[54] = 59; nextgame[55] = nextgame[56] = 60; nextgame[57] = nextgame[58] = 61; nextgame[59] = nextgame[60] = 62; nextgame[61] = nextgame[62] = 63; function All_Picks_Are_Made() { all_picks_made=true; start=1; if (playinGame) {start=0;} for(index=start; index <= 63; index++) { if (pick[index] == 0) {all_picks_made=false;} } return all_picks_made; } function Check_Bracket() { error=false; if (document.Web_Entry.field0.value==''){error=true;} if (error) {alert("Display Name is a required field"); return false;}; if (document.Web_Entry.field1.value==''){error=true;} if (error) {alert("Email is a required field"); return false;}; if (! All_Picks_Are_Made()) {error=true;} if (error) {alert("Some picks are missing. The entire bracket must be completed before you can submit them."); return false;}; if (document.Web_Entry.elements['tiebreaker']) { if (document.Web_Entry.tiebreaker.value==''){error=true;} if (error) {alert("Must fill in a tiebreaker"); return false;}; } // Now let's accumulate all the picks data pData = "" for(index=0; index <= 63; index++) { if (index==63) { pData = pData + pick[index];} else { pData = pData + pick[index] + ",";} } // now need to seet all the fields correctly document.Web_Entry.picks_data.value=pData; // Now need to get in correct format for OfficePool to read //CRLF = chr(13)+Chr(10); CRLF = "\r\n"; if (document.Web_Entry.elements['field0']) { webentrydata = "JavaName:" + document.Web_Entry.field0.value + ":END" + CRLF; } if (document.Web_Entry.elements['field1']) { webentrydata = webentrydata + "JavaEmail:" + document.Web_Entry.field1.value + ":END" + CRLF; } if (document.Web_Entry.elements['tiebreaker']) { webentrydata = webentrydata + "JavaTiebreaker:" + document.Web_Entry.tiebreaker.value + ":END" + CRLF; } if (document.Web_Entry.elements['field2']) { webentrydata = webentrydata + "JavaInfo1:" + document.Web_Entry.field2.value + ":END" + CRLF; } if (document.Web_Entry.elements['field3']) { webentrydata = webentrydata + "JavaInfo2:" + document.Web_Entry.field3.value + ":END" + CRLF; } if (document.Web_Entry.elements['field4']) { webentrydata = webentrydata + "JavaInfo3:" + document.Web_Entry.field4.value + ":END" + CRLF; } if (document.Web_Entry.elements['field5']) { webentrydata = webentrydata + "JavaInfo4:" + document.Web_Entry.field5.value + ":END" + CRLF; } if (document.Web_Entry.elements['field6']) { webentrydata = webentrydata + "JavaInfo5:" + document.Web_Entry.field6.value + ":END" + CRLF; } if (document.Web_Entry.elements['picks_data']) { webentrydata = webentrydata + "JavaData:" + document.Web_Entry.picks_data.value + ":END" + CRLF; } document.Web_Entry.webentry_data.value=webentrydata; return true;} function doClear() { res=confirm("Are you sure you want to clear all picks?"); if(!res) return; for(index=1; index <= 63; index++) { Chose_Tm(index,0); } advanceToTheResults(); } function pickFavorites() { res=confirm('Are you sure you want to pick higher seeds to win through round 4?\n (This will replace any picks you have made.)'); if(!res) return; // First round games advanceToTheResults(); for(index=1; index <= 60; index++) { if(userpick[index]==0) Chose_Tm(index,favs[index]); } } function advanceToTheResults() { for(index=1; index <= 63; index++) { Chose_Tm(index,userpick[index]); } } // Added by PRC 11-3-2003 var rec = new Array(65); var team = new Array(65); var regions = new Array(3); var userpick = new Array(63); team[0]=""; <?php $sql = mysql_query("SELECT * FROM `1`"); while($row = mysql_fetch_array($sql)){ ?> team[1]="<?php echo $row['1']; ?>"; rec[1]="(<?php echo $row['w1a']."-".$row['l1a']; ?>)"; team[2]="<?php echo $row['16']; ?>"; rec[2]="(<?php echo $row['w16a']."-".$row['l16a']; ?>)"; team[3]="<?php echo $row['8']; ?>"; rec[3]="(<?php echo $row['w8a']."-".$row['l8a']; ?>)"; team[4]="<?php echo $row['9']; ?>"; rec[4]="(<?php echo $row['w9a']."-".$row['l9a']; ?>)"; team[5]="<?php echo $row['5']; ?>"; rec[5]="(<?php echo $row['w5a']."-".$row['l5a']; ?>)"; team[6]="<?php echo $row['12']; ?>"; rec[6]="(<?php echo $row['w12a']."-".$row['l12a']; ?>)"; team[7]="<?php echo $row['4']; ?>"; rec[7]="(<?php echo $row['w4a']."-".$row['l4a']; ?>)"; team[8]="<?php echo $row['13']; ?>"; rec[8]="(<?php echo $row['w13a']."-".$row['l13a']; ?>)"; team[9]="<?php echo $row['6']; ?>"; rec[9]="(<?php echo $row['w6a']."-".$row['l6a']; ?>)"; team[10]="<?php echo $row['11']; ?>"; rec[10]="(<?php echo $row['w11a']."-".$row['l11a']; ?>)"; team[11]="<?php echo $row['3']; ?>"; rec[11]="(<?php echo $row['w3a']."-".$row['l3a']; ?>)"; team[12]="<?php echo $row['14']; ?>"; rec[12]="(<?php echo $row['w14a']."-".$row['l14a']; ?>)"; team[13]="<?php echo $row['7']; ?>"; rec[13]="(<?php echo $row['w7a']."-".$row['l7a']; ?>)"; team[14]="<?php echo $row['10']; ?>"; rec[14]="(<?php echo $row['w10a']."-".$row['l10a']; ?>)"; team[15]="<?php echo $row['2']; ?>"; rec[15]="(<?php echo $row['w2a']."-".$row['l2a']; ?>)"; team[16]="<?php echo $row['15']; ?>"; rec[16]="(<?php echo $row['w15a']."-".$row['l15a']; ?>)"; <?php } $sql = mysql_query("SELECT * FROM `2`"); while($row = mysql_fetch_array($sql)){ ?> team[17]="<?php echo $row['1']; ?>"; rec[17]="(<?php echo $row['w1b']."-".$row['l1b']; ?>)"; team[18]="<?php echo $row['16']; ?>"; rec[18]="(<?php echo $row['w16b']."-".$row['l16b']; ?>)"; team[19]="<?php echo $row['8']; ?>"; rec[19]="(<?php echo $row['w8b']."-".$row['l8b']; ?>)"; team[20]="<?php echo $row['9']; ?>"; rec[20]="(<?php echo $row['w9b']."-".$row['l9b']; ?>)"; team[21]="<?php echo $row['5']; ?>"; rec[21]="(<?php echo $row['w5b']."-".$row['l5b']; ?>)"; team[22]="<?php echo $row['12']; ?>"; rec[22]="(<?php echo $row['w12b']."-".$row['l12b']; ?>)"; team[23]="<?php echo $row['4']; ?>"; rec[23]="(<?php echo $row['w4b']."-".$row['l4b']; ?>)"; team[24]="<?php echo $row['13']; ?>"; rec[24]="(<?php echo $row['w13b']."-".$row['l13b']; ?>)"; team[25]="<?php echo $row['6']; ?>"; rec[25]="(<?php echo $row['w6b']."-".$row['l6b']; ?>)"; team[26]="<?php echo $row['11']; ?>"; rec[26]="(<?php echo $row['w11b']."-".$row['l11b']; ?>)"; team[27]="<?php echo $row['3']; ?>"; rec[27]="(<?php echo $row['w3b']."-".$row['l3b']; ?>)"; team[28]="<?php echo $row['14']; ?>"; rec[28]="(<?php echo $row['w14b']."-".$row['l14b']; ?>)"; team[29]="<?php echo $row['7']; ?>"; rec[29]="(<?php echo $row['w7b']."-".$row['l7b']; ?>)"; team[30]="<?php echo $row['10']; ?>"; rec[30]="(<?php echo $row['w10b']."-".$row['l10b']; ?>)"; team[31]="<?php echo $row['2']; ?>"; rec[31]="(<?php echo $row['w2b']."-".$row['l2b']; ?>)"; team[32]="<?php echo $row['15']; ?>"; rec[32]="(<?php echo $row['w15b']."-".$row['l15b']; ?>)"; <?php } $sql = mysql_query("SELECT * FROM `3`"); while($row = mysql_fetch_array($sql)){ ?> team[33]="<?php echo $row['1']; ?>"; rec[33]="(<?php echo $row['w1c']."-".$row['l1c']; ?>)"; team[34]="<?php echo $row['16']; ?>"; rec[34]="(<?php echo $row['w16c']."-".$row['l16c']; ?>)"; team[35]="<?php echo $row['8']; ?>"; rec[35]="(<?php echo $row['w8c']."-".$row['l8c']; ?>)"; team[36]="<?php echo $row['9']; ?>"; rec[36]="(<?php echo $row['w9c']."-".$row['l9c']; ?>)"; team[37]="<?php echo $row['5']; ?>"; rec[37]="(<?php echo $row['w5c']."-".$row['l5c']; ?>)"; team[38]="<?php echo $row['12']; ?>"; rec[38]="(<?php echo $row['w12c']."-".$row['l12c']; ?>)"; team[39]="<?php echo $row['4']; ?>"; rec[39]="(<?php echo $row['w4c']."-".$row['l4c']; ?>)"; team[40]="<?php echo $row['13']; ?>"; rec[40]="(<?php echo $row['w13c']."-".$row['l13c']; ?>)"; team[41]="<?php echo $row['6']; ?>"; rec[41]="(<?php echo $row['w6c']."-".$row['l6c']; ?>)"; team[42]="<?php echo $row['11']; ?>"; rec[42]="(<?php echo $row['w11c']."-".$row['l11c']; ?>)"; team[43]="<?php echo $row['3']; ?>"; rec[43]="(<?php echo $row['w3c']."-".$row['l3c']; ?>)"; team[44]="<?php echo $row['14']; ?>"; rec[44]="(<?php echo $row['w14c']."-".$row['l14c']; ?>)"; team[45]="<?php echo $row['7']; ?>"; rec[45]="(<?php echo $row['w7c']."-".$row['l7c']; ?>)"; team[46]="<?php echo $row['10']; ?>"; rec[46]="(<?php echo $row['w10c']."-".$row['l10c']; ?>)"; team[47]="<?php echo $row['2']; ?>"; rec[47]="(<?php echo $row['w2c']."-".$row['l2c']; ?>)"; team[48]="<?php echo $row['15']; ?>"; rec[48]="(<?php echo $row['w15c']."-".$row['l15c']; ?>)"; <?php } $sql = mysql_query("SELECT * FROM `4`"); while($row = mysql_fetch_array($sql)){ ?> team[49]="<?php echo $row['1']; ?>"; rec[49]="(<?php echo $row['w1d']."-".$row['l1d']; ?>)"; team[50]="<?php echo $row['16']; ?>"; rec[50]="(<?php echo $row['w16d']."-".$row['l16d']; ?>)"; team[51]="<?php echo $row['8']; ?>"; rec[51]="(<?php echo $row['w8d']."-".$row['l8d']; ?>)"; team[52]="<?php echo $row['9']; ?>"; rec[52]="(<?php echo $row['w9d']."-".$row['l9d']; ?>)"; team[53]="<?php echo $row['5']; ?>"; rec[53]="(<?php echo $row['w5d']."-".$row['l5d']; ?>)"; team[54]="<?php echo $row['12']; ?>"; rec[54]="(<?php echo $row['w12d']."-".$row['l12d']; ?>)"; team[55]="<?php echo $row['4']; ?>"; rec[55]="(<?php echo $row['w4d']."-".$row['l4d']; ?>)"; team[56]="<?php echo $row['13']; ?>"; rec[56]="(<?php echo $row['w13d']."-".$row['l13d']; ?>)"; team[57]="<?php echo $row['6']; ?>"; rec[57]="(<?php echo $row['w6d']."-".$row['l6d']; ?>)"; team[58]="<?php echo $row['11']; ?>"; rec[58]="(<?php echo $row['w11d']."-".$row['l11d']; ?>)"; team[59]="<?php echo $row['3']; ?>"; rec[59]="(<?php echo $row['w3d']."-".$row['l3d']; ?>)"; team[60]="<?php echo $row['14']; ?>"; rec[60]="(<?php echo $row['w14d']."-".$row['l14d']; ?>)"; team[61]="<?php echo $row['7']; ?>"; rec[61]="(<?php echo $row['w7d']."-".$row['l7d']; ?>)"; team[62]="<?php echo $row['10']; ?>"; rec[62]="(<?php echo $row['w10d']."-".$row['l10d']; ?>)"; team[63]="<?php echo $row['2']; ?>"; rec[63]="(<?php echo $row['w2d']."-".$row['l2d']; ?>)"; team[64]="<?php echo $row['15']; ?>"; rec[64]="(<?php echo $row['w15d']."-".$row['l15d']; ?>)"; /*not too sure what this is*/ team[65]="<?php echo $row['1']; ?>"; rec[65]="(<?php echo $row['w1d']."-".$row['l1d']; ?>)"; <?php } $sql = mysql_query("SELECT * FROM `1`"); while($row = mysql_fetch_array($sql)){ ?> regions[0]="<?php echo $row['region']; ?>"; <?php } $sql = mysql_query("SELECT * FROM `2`"); while($row = mysql_fetch_array($sql)){ ?> regions[1]="<?php echo $row['region']; ?>"; <?php } $sql = mysql_query("SELECT * FROM `3`"); while($row = mysql_fetch_array($sql)){ ?> regions[2]="<?php echo $row['region']; ?>"; <?php } $sql = mysql_query("SELECT * FROM `4`"); while($row = mysql_fetch_array($sql)){ ?> regions[3]="<?php echo $row['region']; ?>"; <?php } ?> userpick[0]=0; userpick[1]=0; userpick[2]=0; userpick[3]=0; userpick[4]=0; userpick[5]=0; userpick[6]=0; userpick[7]=0; userpick[8]=0; userpick[9]=0; userpick[10]=0; userpick[11]=0; userpick[12]=0; userpick[13]=0; userpick[14]=0; userpick[15]=0; userpick[16]=0; userpick[17]=0; userpick[18]=0; userpick[19]=0; userpick[20]=0; userpick[21]=0; userpick[22]=0; userpick[23]=0; userpick[24]=0; userpick[25]=0; userpick[26]=0; userpick[27]=0; userpick[28]=0; userpick[29]=0; userpick[30]=0; userpick[31]=0; userpick[32]=0; userpick[33]=0; userpick[34]=0; userpick[35]=0; userpick[36]=0; userpick[37]=0; userpick[38]=0; userpick[39]=0; userpick[40]=0; userpick[41]=0; userpick[42]=0; userpick[43]=0; userpick[44]=0; userpick[45]=0; userpick[46]=0; userpick[47]=0; userpick[48]=0; userpick[49]=0; userpick[50]=0; userpick[51]=0; userpick[52]=0; userpick[53]=0; userpick[54]=0; userpick[55]=0; userpick[56]=0; userpick[57]=0; userpick[58]=0; userpick[59]=0; userpick[60]=0; userpick[61]=0; userpick[62]=0; userpick[63]=0; // Initialize var pick = new Array(63); for(index=0; index <= 63; index++) { pick[index]=0; } // Used to pick the favorites var favs = new Array(63); for(index=1; index <= 32; index++) { favs[index] = 2*index-1; } favs[33]=1;favs[34]=4;favs[35]=6;favs[36]=8; favs[37]=9;favs[38]=12;favs[39]=14;favs[40]=16; favs[41]=17;favs[42]=20;favs[43]=22;favs[44]=24; favs[45]=25;favs[46]=28;favs[47]=30;favs[48]=32; favs[49]=33;favs[50]=36;favs[51]=37;favs[52]=40; favs[53]=41;favs[54]=44;favs[55]=45;favs[56]=48; favs[57]=49;favs[58]=51;favs[59]=53;favs[60]=55; // Added for 2006 function GetRegionHTML(regionName) { var html = "<br>"; //res=confirm("This is a test "+ regionName.substr(0,1)); var cnt=regionName.length; //res=confirm("This is a test "+ cnt); for(c=0; c < cnt; c++) { html = html + regionName.charAt(c) + "<br>"; } //res=confirm(html); html = html + "<br>"; return html; } </script> Quote Link to comment https://forums.phpfreaks.com/topic/90455-java-php-mysql-how/ Share on other sites More sharing options...
teng84 Posted February 11, 2008 Share Posted February 11, 2008 java or JavaScript? maybe you need ajax ! Quote Link to comment https://forums.phpfreaks.com/topic/90455-java-php-mysql-how/#findComment-463746 Share on other sites More sharing options...
Lamez Posted February 11, 2008 Author Share Posted February 11, 2008 Javascript, sorry. I rather use this, since I have it all setup, I just do not know how to process the variables (Javascript) to php. Quote Link to comment https://forums.phpfreaks.com/topic/90455-java-php-mysql-how/#findComment-463758 Share on other sites More sharing options...
teng84 Posted February 11, 2008 Share Posted February 11, 2008 YEAH java is different from JS.. you can't make your JS works like a server script if you need to pass the var in your db without submitting the form then you need AJAX! if you want to use the submit button then you can use hidden fields pass the values generated by your JS to your hidden fields so when you submit the form it has the values you recreated using JS! Quote Link to comment https://forums.phpfreaks.com/topic/90455-java-php-mysql-how/#findComment-463761 Share on other sites More sharing options...
Trekx Posted February 11, 2008 Share Posted February 11, 2008 That code is setting values in a form called Web_Entry, which would be sent to a PHP script when the visitor clicks Submit, and accessible to the script in the $_POST or $_GET variables. Quote Link to comment https://forums.phpfreaks.com/topic/90455-java-php-mysql-how/#findComment-463762 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.