Jump to content

Lamez

Members
  • Posts

    1,686
  • Joined

  • Last visited

    Never

Everything posted by Lamez

  1. 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>
  2. Lamez

    Any Errors

    when I select a user, it is suppose to add the user to the paid databse, well it does, but then it suppose to show a link if they are in the paid table. Well it shows it on the wrong user.
  3. Lamez

    Any Errors

    I am very sorry. Those include files are just my heading, and the file to tell if the user is logged in or not(session.php), and my footer. Those are not the problems. I do have shot tags enabled. I did not get any errors, but the scripts does not run properly
  4. Can someone review my code, and see if there are any errors. What it is suppose to do, is see if the user is in the paid table, and if they are show a link, but if the user is not in the paid table show a checkbox. So please just look over my code for errors <?php include ("../../style/include/session.php"); include ("../../style/include/cons/head_2.php"); if($session->isAdmin()){ print '<div class="box"><h2>Select Paid</h2>'; ?> <form action="pay_do.php" method="post"> <table width="63%" border="0"> <tr> <td width="194"><strong>First Name </strong></td> <td width="261"><strong>Last Name </strong></td> <td width="273"><strong>Paid (username) </strong></td> </tr> <? $qr=mysql_query("select * from users order by first"); $pt=mysql_query("select * from paid order by user"); while ($rs=mysql_fetch_assoc($qr)) { $pu=mysql_fetch_assoc($pt); $table = 'paid'; $field = 'user'; $compared = $pu['user']; $result = mysql_query("SELECT $field FROM $table WHERE $field = '$compared'"); ?> <tr> <td><? echo $rs['first'];?></td> <td><? echo $rs['last'];?></td> <td> <? if(mysql_num_rows($result)==0) { //"Not Paid "; ?> <input type="checkbox" name="checkbox[]" value="<? echo $rs['username'] ?>" /> <?php } else { echo '<a href="pay_dele.php?cmd=delete&user='.$rs['username'].'">Not Paid</a> '; } ?> (<? echo $rs['username']; ?>) </td> <? } ?> </tr> </table> <br /> <input name="Submit" type="Submit" value="Mark Paid" /> </form> <?php }else{ header("Location: ../../index.php"); } print '</div>'; include ("../../style/include/cons/foot.php"); ?>
  5. I am not too sure what is wrong with this page, If I select one as paid, then view the page again it shows a link, like I want, but If I select another person, after already selecting one before (at different times) it shows checkboxes saying they are not in the paid table. I think it is this page that has bad coding in it, will you view over it? <?php include ("../../style/include/session.php"); include ("../../style/include/cons/head_2.php"); if($session->isAdmin()){ print '<div class="box"><h2>Select Paid</h2>'; ?> <form action="pay_do.php" method="post"> <table width="63%" border="0"> <tr> <td width="194"><strong>First Name </strong></td> <td width="261"><strong>Last Name </strong></td> <td width="273"><strong>Paid (username) </strong></td> </tr> <? $qr=mysql_query("select * from users order by first"); $pt=mysql_query("select * from paid order by user"); while ($rs=mysql_fetch_assoc($qr)) { $pu=mysql_fetch_assoc($pt); $table = 'paid'; $field = 'user'; $compared = $pu['user']; $result = mysql_query("SELECT $field FROM $table WHERE $field = '$compared'"); ?> <tr> <td><? echo $rs['first'];?></td> <td><? echo $rs['last'];?></td> <td> <? if(mysql_num_rows($result)==0) { //"Not Paid "; ?> <input type="checkbox" name="checkbox[]" value="<? echo $rs['username'] ?>" /> <?php } else { echo '<a href="pay_dele.php?cmd=delete&user='.$rs['username'].'">Not Paid</a> '; } ?> (<? echo $rs['username']; ?>) </td> <? } ?> </tr> </table> <br /> <input name="Submit" type="Submit" value="Mark Paid" /> </form> <?php }else{ header("Location: ../../index.php"); } print '</div>'; include ("../../style/include/cons/foot.php"); ?>
  6. I would, but is it not down there as usual
  7. wow thank you very very much! I am very thankful to have someone like you helping me!
  8. Yes, but the system is not working, and I have gone over, and over the scripts. When I select only one person as paid, it adds them only to the paid table. Then it says all the users have paid. Then it adds a blank row to the db, every time I select someone.
  9. [pre]What is this[/pre] just lookin at the new update. Preformatted Text
  10. this is my outcome when I only select Admin this is my outcome, when I select all.
  11. any ideas?
  12. If I select one person, it still says everyone has paid even when they are not in the paid table.
  13. My paid system for a website I am working on, It is suppose list all the users in a table, and tell if the user has paid for not. If they have paid then it shows a link, to remove them from the paid table. If they have not paid (not in the paid table), then it is suppose to show a check box so I can check the users who have paid, and add them to the paid table. Well the only part that works is show the users from the username table. It does show a checkbox or a link, but if I select one user that has paid, it show everyone on the list as paid, even when they are not in the paid table. It also adds a blank row in the table. So can someone review my code and tell me what I could do better. paid.php (shows list, and deter minds who has paid, and shows link or checkbox) <?php include ("../../style/include/session.php"); include ("../../style/include/cons/head_2.php"); if($session->isAdmin()){ print '<div class="box"><h2>Select Paid</h2>'; ?> <form action="pay_do.php" method="post"> <table width="63%" border="0"> <tr> <td width="194"><strong>First Name </strong></td> <td width="261"><strong>Last Name </strong></td> <td width="273"><strong>Paid (username) </strong></td> </tr> <? $qr=mysql_query("select * from users order by first"); $pt=mysql_query("select * from paid order by user"); while ($rs=mysql_fetch_assoc($qr)) { $pu=mysql_fetch_assoc($pt); $table = 'paid'; $field = 'user'; $compared = $pu['user']; $result = mysql_query("SELECT $field FROM $table WHERE $field = '$compared'"); ?> <tr> <td><? echo $rs['first'];?></td> <td><? echo $rs['last'];?></td> <td> <? if(mysql_num_rows($result)==0) { //"Not Paid "; ?> <input type="checkbox" name="checkbox[]" onchange="if(this.checked) { this.value='<? echo $rs['username'] ?>'; } else { this.value=''; }" /> <?php } else { echo "Paid "; } ?> (<? echo $rs['username']; ?>) </td> <? } ?> </tr> </table> <br /> <input name="Submit" type="Submit" value="Mark Paid" /> </form> <?php }else{ header("Location: ../../index.php"); } print '</div>'; include ("../../style/include/cons/foot.php"); ?> paid_do.php (adds the user to the paid table) <?php include ("../../style/include/session.php"); include ("../../style/include/cons/head_2.php"); print '<div class="box">'; if($session->isAdmin()){ if(isset($_POST['Submit'])){ $boxes=$_POST['checkbox']; $i=0; while ($i<=count($boxes)) { if($boxes[$i]!=='') { mysql_query("insert into paid (user) values ('$boxes[$i]')"); } $i++; } echo "<h2>Processed</h2>"; echo "Selected users have been processed"; }else{ echo "<h2>Error!</h2>"; echo 'No data to process<br><a href="paid.php">Select Paid/Non-Paid</a>'; } }else{ header("Location: ../../index.php"); } print '</div>'; include ("../../style/include/cons/foot.php"); ?> -Thanks Guys!
  14. Right, but how do I assign the username? It pulls it out of the loop. I am confused
  15. I have this code here, it is a function to see if the user is in one table and in the other table. anyways I have a function in the middle of the loop, I can only declare it once, but since it is a loop, it re-declares the function. here is my code: <? $qr=mysql_query("select * from users order by first"); $pt=mysql_query("select * from paid order by user"); while ($rs=mysql_fetch_assoc($qr)) { $pu=mysql_fetch_assoc($pt); $table = 'paid'; $field = 'user'; $compared = $pu['user']; function checkUnique($table, $field, $compared){ if (get_magic_quotes_gpc()) { $table = stripslashes($table); $field = stripslashes($field); $compared = stripslashes($compared); } $table = mysql_real_escape_string($table); $field = mysql_real_escape_string($field); $compared = mysql_real_escape_string($compared); $result = mysql_query("SELECT $field FROM $table WHERE $field = '$compared'"); if(mysql_num_rows($result)==0) { return TRUE; echo "Paid"; } else { return FALSE; echo "Not Paid"; } } How do I fix this to only declare once? I get this error:
  16. Thanks!
  17. from my original code, what is wrong?
  18. alright, but now it does not update. I can insert a row, but now it will not add the new content after I edit it
  19. I have never used an update query, can you show me how?
  20. My script is suppose to detect if there is a row, and if there is it deletes it, then adds the new values well all it does is delete, I cannot get it to add anything. <?php $name = $_POST['name']; $url = $_POST['url']; $content = $_POST['index']; $title = $_POST['title']; $id = $_POST['id']; $q = "Select count(*) as row_count from `home` WHERE id = 1"; $r = mysql_query($q) or die(mysql_error()."<br /><br />".$q); if(mysql_num_rows($r) >0) { $query = "DELETE FROM `home` WHERE id = 1"; $result = mysql_query($query); $q = "INSERT INTO `home` VALUES ('$id', '$title', '$content')"; }else{ $q = "INSERT INTO `home` VALUES ('$id', '$title', '$content')"; } echo $name." has been editied"; echo " You view it here: <a href=".$url.">".$name."</a>."; ?>
  21. so where it says return true, that is where I want to put my link, and the false is the checkbox
  22. you could just take out all html of your script, except the link, and see if it is the invalid html causing your error
  23. any ideas?
  24. ok I made this code: <form action="pay_do.php" method="post"> <table width="100%" border="0"> <tr> <td width="419"><strong>First Name </strong></td> <td width="487"><strong>Last Name </strong></td> <td width="257"><strong>Paid (username) </strong></td> </tr> <? $qr=mysql_query("select * from users order by first"); $pt=mysql_query("select * from paid order by user"); while ($rs=mysql_fetch_assoc($qr)) { $pu=mysql_fetch_assoc($pt) ?> <tr> <td><? echo $rs['first'];?></td> <td><? echo $rs['last'];?></td> <td> <? if ($pu['user'] == ($rs['username'])){ print '<a href="new">Not Paid</a> '; }else{ ?> <input type="checkbox" name="checkbox[]" onchange="if(this.checked) { this.value='<?=$rs['username'] ?>'; } else { this.value=''; }" /> <? } ?> (<? echo $rs['username']; ?>) </td> <? } ?> </tr> </table> <br /> <input name="Submit" type="Submit" value="Mark Paid" /> </form> When I select the admin, it adds him to the table paid, then when I go back it shows the link, not the checkbox, but then when I submit googlebot, it comes back, and they are both checkboxs, what is wrong?
×
×
  • 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.