Jump to content

Lamez

Members
  • Posts

    1,686
  • Joined

  • Last visited

    Never

Everything posted by Lamez

  1. I have this JS code here: userpick[0]=0; It is just a snippet. How do I set it as a php variable, but it still can be processed as a JS variable? like this maybe? $a = userpick[0]=0;
  2. I am making a bracket based website for my dad, for the NCAA. Anyways, I have never used ajax, and I told I was making a bracket based website so you could get a better understanding, of what I am asking for help on. I need some drop down list that will update the next one based on what was just selected, and add the selections to a database. Example: Round 1 Team A *User selected* Team B Round 2 Team A Team C *User Selected* Round 3 Team C Team D and so on... -Thanks!
  3. oh I got it, lol just like naming a variable $name = "Jones"; echo $name; Well this is my latest code, wanna look over it for errors? <?php include ("../../style/include/session.php"); if($session->logged_in){ $user = $session->username; $points = "select * from points"; $uspo = "select username WHERE username = $user from userpoints"; $win = "select * from winners"; $uspick = "select * from userpicks"; $pnt = mysql_query($points) or die(mysql_error()); $usp = mysql_query($uspo) or die(mysql_error()); $wn = mysql_query($win) or die(mysql_error()); $up = mysql_query($uspick) or die (mysql_error()); $rs = mysql_fetch_array($pnt); $userp = mysql_fetch_array($usp); $winr = mysql_fetch_array($wn); $uspck = mysql_fetch_array($up); $enc = md5("action"); $r1 = md5("round1"); $r2 = md5("round1"); $r3 = md5("round3"); if ($_GET[$enc] === ($r1)){ if ($userp['1'] === ('0')){ if ($uspck['1'] === ($winr['1'])){ $new = $rs['1'] + $userp['total']; $q = "UPDATE `userpoints` SET `total`=$new, `1`=1 WHERE `username`='$user'"; mysql_query($q); echo "You Won ".$new." points<br>"; echo "You have ".$userp['total']." total points"; }else{ echo "no win"; } }else{ echo "You have already played this round!"; } echo '<br><a href="?">Index</a>'; } elseif ($_GET[$enc] === ($r2)){ if ($userp['2'] === ('0')){ if ($uspck['2'] === ($winr['2'])){ $new = $rs['2'] + $userp['total']; $q = "UPDATE `userpoints` SET `total`=$new, `2`=1 WHERE `username`='$user'"; mysql_query($q); echo "You Won ".$new." points<br>"; echo "You have ".$userp['total']." total points"; }else{ echo "no win"; } }else{ echo "You have already played this round!"; } echo '<br><a href="?">Index</a>'; } elseif ($_GET[$enc] === ($r3)){ if ($userp['3'] === ('0')){ if ($uspck['3'] === ($winr['3'])){ $new = $rs['3'] + $userp['total']; $q = "UPDATE `userpoints` SET `total`=$new, `3`=1 WHERE `username`='$user'"; mysql_query($q); echo "You Won ".$new." points<br>"; echo "You have ".$userp['total']." total points"; }else{ echo "no win"; } }else{ echo "You have already played this round!"; } echo '<br><a href="?">Index</a>'; }else{ echo '<a href=?'.$enc.'='.$r1.'>Round 1</a><br>'; echo '<a href=?'.$enc.'='.$r2.'>Round 2</a><br>'; echo '<a href=?'.$enc.'='.$r3.'>Round 3</a><br>'; echo 'Total Points: '.$userp['total']; echo '<br><a href="standings.php">Standings</a>'; } }else{ echo "login"; } ?>
  4. use this, sorry read the post wrong <?php $boxes = $_POST['checkbox']; foreach($boxes as &$value){ if($value!=='') { //YOUR DELETE CODE } ?>
  5. you need a form action, and a submit button, but if you are trying to make it delete when you select it right then instead of clicking a button to activate the form action, then you might need to look into some JS (Javascript). http://www.google.com/search?q=click+checkbox+for+form+action+JS&btnG=Search&hl=en&safe=off
  6. I have never used math at all in php, this is my first script. This script is suppose to pull the info from the winners table, and the user picks, from the userpicks table, and if the rows are equal then add the points from the points table, to the value in the userpoints table, then add it to the database here is what I have: I do not think it is correct, I just took a shot in the dark with the math, but it does not add it to the database, that is why I am posting. So are there any errors? <?php include ("../../style/include/session.php"); if($session->logged_in){ $user = $session->username; $points = "select * from points"; $uspo = "select * from userpoints"; $win = "select * from winners"; $uspick = "select * from userpicks"; $pnt = mysql_query($points) or die(mysql_error()); $usp = mysql_query($uspo) or die(mysql_error()); $wn = mysql_query($win) or die(mysql_error()); $up = mysql_query($uspick) or die (mysql_error()); $rs = mysql_fetch_array($pnt); $userp = mysql_fetch_array($usp); $winr = mysql_fetch_array($wn); $uspck = mysql_fetch_array($up); if ($uspck['1'] === ($winr['1'])){ $rs['1'] + $userp['total'] = $new; $q = "UPDATE `userpoints` SET `total`=$new WHERE `username`='$user'"; mysql_query($q); echo "You Won ".$rs['1']." points"; echo "You have".$new."total points"; }else{ echo "no win"; } }else{ echo "login"; } ?>
  7. <?php if(isset($_POST['Submit'])){ $boxes = $_POST['checkbox']; foreach($boxes as &$value){ if($value!=='') { $q = "DELETE FROM forum WHERE postid=$covid"; echo $q.'<br />'; mysql_query($q); } } echo "<h2>Processed</h2>"; echo 'Selected users have been processed<br><a href="index.php">board</a>'; }else{ echo "<h2>Error!</h2>"; echo 'No data to process<br><a href="index.php">Back</a>'; } ?> use this as your form process, see what you can do with that
  8. try if ($sending == ('yes')){ //other code }
  9. I have a code like this, here is my script for my paid system, see what you can do with it: <?php $paid = "select * from users order by paid"; $q = mysql_query($paid) or die('Error: ' . mysql_error()); while ($rs=mysql_fetch_array($q)) { $id = $rs['username']; ?> <tr> <td><? echo $rs['first'];?> </td> <td><? echo $rs['last'];?></td> <td> <?php If($rs['paid'] == 0 ){ echo '<input type="checkbox" name="checkbox[]" value="'.$rs['username'].'" />'; } elseif($rs['paid'] == 1 ){ echo "<a href='pay_dele.php?cmd=delete&id=$id'>Paid</a>"; } echo " (".$rs['username'].")"; } ?> </td> </tr> </table>
  10. is your password correct? If you do not have a password, then set it like this $this->dbPassword = "";
  11. Alright I changed the code to: <?php $getlink = $_GET["action"]; $link = md5("addpointstodb"); if ($getlink == $link) { if(isset ($_POST['Submit'])){ $a = $_POST['1']; $b = $_POST['2']; $c = $_POST['3']; $d = $_POST['4']; $e = $_POST['5']; $f = $_POST['6']; $g = $_POST['7']; $q = "Select count(*) as row_count from `points`"; $r = mysql_query($q) or die(mysql_error()."<br /><br />".$q); if(mysql_num_rows($r) >0){ $q = "UPDATE `points` SET `1`=$a, `2`=$b, `3`=$c, `4`=$d, `5`=$e , `6`=$f, `7`=$g WHERE `1`='$a'"; mysql_query($q)or die(mysql_error()); echo "Updated Points to Database"; echo '<br><br><a href="pinval.php">View Points</a>'; }else{ $q = "INSERT INTO `points` VALUES ('$a', '$b', '$c', '$d', '$e', '$f', '$g')"; mysql_query($q); echo "Added points to Database"; echo '<br><br><a href="pinval.php">View Points</a>'; } }else{ echo "No data to enter"; echo '<br><br><a href="pinval.php">Try Again</a>'; } }else{ //HTML FORM BELOW ?> And it still will not add the newly written values to the DB! WHY?
  12. I think there is something wrong with my query, it is not adding it to the database is there something wrong in my code? <?php $getlink = $_GET["action"]; $link = md5("addpointstodb"); if ($getlink == $link) { if(isset ($_POST['Submit'])){ $q = "Select count(*) as row_count from `points`"; $r = mysql_query($q) or die(mysql_error()."<br /><br />".$q); $a = $_POST['1']; $b = $_POST['2']; $c = $_POST['3']; $d = $_POST['4']; $e = $_POST['5']; $f = $_POST['6']; $g = $_POST['7']; if(mysql_num_rows($r) >0){ $q = "UPDATE `points` SET `1`=$a, `2`=$b, `3`=$c, `4`=$d, `5`=$e , `6`=$f, `7`=$g WHERE `1`='$a', `2`='$b', `3`='$c', `4`='$d', `5`='$e', `6`='$f', `7`='$g'"; echo "Update Points to Database"; mysql_query($q); }else{ $q = "INSERT INTO `points` VALUES ('$a', '$b', '$c', '$d', '$e', '$f', '$g')"; mysql_query($q); echo "Add points to Database"; echo '<br><br><a href="pinval.php">View Points</a>'; } }else{ echo "No data to enter"; echo '<br><br><a href="pinval.php">Try Again</a>'; } }else{ ?>
  13. Ya that sounds like it, in my DB table I have 1 2 3 4 5 6 7 and I want to update them with the respective post variable (i.e $_POST['1'] = column 1)
  14. How do I use MySQL's update function with more than one value? I have values that range from 1-7, but I do not know how to update more than one column here is my code <?php $getlink = $_GET["action"]; $link = md5("addpointstodb"); if ($getlink == $link) { if(isset $_POST['Submit'])){ $q = "Select count(*) as row_count from `points`"; $r = mysql_query($q) or die(mysql_error()."<br /><br />".$q); $a = $_POST['1']; $b = $_POST['2']; $c = $_POST['3']; $d = $_POST['4']; $e = $_POST['5']; $f = $_POST['6']; $g = $_POST['7']; if(mysql_num_rows($r) >0){ $q = "UPDATE `points` SET `1`=$a WHERE `1`='$a'"; mysql_query($q); }else{ $q = "INSERT INTO `points` VALUES ('$a', '$b', '$c', '$d', '$e', '$f', '$g')"; mysql_query($q); } }else{ ?> -Thanks!
  15. Oh, well that is crazy. I cannot help you there. Just because I am curious what are you doing this for?
  16. when you set the name that will be your post variable here is an example: <form id="form1" name="form1" method="post" action=""> <input name="name" type="text" id="name" /> <input type="submit" name="Submit" value="Submit" /> </form> <?php $name = $_POST['name']; echo $name; ?> Instead of writing it to a file, you should do a database!
  17. alright I got the code, I wrote it myself <?php $q = mysql_query("Select * from `users` where username='$session->username'"); $rs=mysql_fetch_array($q); $paid = $rs['paid']; if ($paid === ('0')){ echo "<br><br><h3>You have not paid yet.</h3>"; }else{ echo "[You have paid!]"; } ?> -Topic Solved!
  18. I have not written my update code yet. TABLE NAME: users username password userid first last zip yahoo aim paid $session->username that defines the current user that is logged in
  19. That did, but now I gotta change it in the dashboard. How would I write this code for one individual user? here is my old code: (the paid table is now a column in the users table) $q = mysql_query("Select * from `paid` where user='$session->username'"); if(mysql_num_rows($q)=='0'){ echo "<br><h3>You have not paid yet.</h3>"; }else{ echo "[You have paid!]"; }
  20. I get this error: here is my PHP code: <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> <?php $paid = "select * from users order by last"; $paid = mysql_query($sql) or die('Error: ' . mysql_error()); while ($rs=mysql_fetch_assoc($paid)) { ?> <tr> <td><? echo $rs['first'];?></td> <td><? echo $rs['last'];?></td> <td> <?php If($paid == 0 ){ echo "Unpaid"; } elseif($paid == 1 ){ echo "Paid"; } echo "(".$rs['username'].")"; } ?> </td> </tr> </table> lol, what does that mean?
  21. right, but how do I do this with a loop, and it changes the message with different usernames? here is my old code: (now the paid value is in one table w/ the usernames) $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>
  22. Alright, I have redesigned my paid system. Now if they have a 0 in the paid column, then is shows them as not paid, but if they have a 1 then they have paid. However, I do not know how to write a IF statement with a MySQL statement. Could someone post an example thanks!
  23. it says failed to open, means it cannot find the file. Make sure you spelt the path right. Make sure that file is in the location it is being called from.
  24. 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.
×
×
  • 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.