-
Posts
1,686 -
Joined
-
Last visited
Never
Everything posted by Lamez
-
Revraz is this the function you are talking about? 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; } else { return FALSE; } }
-
Can I do a if statement to tell if the user is also in another table? The user is in the default table, but if he is in the paid table, make a link, if not make a check box. How would I be able to do this? -- Also How do I make it where the user can only be in the table once? because I have a table, and every time I submit data, even though the user is already in there, it adds them again.
-
it still adds a blank row, along with the selected user. That is ok I can live with that.
-
sure did, I just copied and pasted paid.php <?php include ("../../style/include/session.php"); include ("../../style/include/cons/head_2.php"); print '<div class="box"><h2>Select Paid</h2>'; if($session->isAdmin()){ ?> <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"); while ($rs=mysql_fetch_assoc($qr)) { ?> <tr> <td><? echo $rs['first'];?></td> <td><? echo $rs['last'];?></td> <td><input type="checkbox" name="checkbox[]" onclick="if(this.value=='on') { this.value='<?=$rs['username'] ?>'; } if(this.value=='<?=$rs['username'] ?>') { this.value=''; }" /> (<? 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"); ?> pay_do.php: <?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"); ?>
-
now it just inserts a blank row
-
take a look here: http://adsense.google.com
-
well how do I set the value? like this? <input type="checkbox" name="checkbox[]" value="<?=$rs['username'] ?>" /> so then I need to change this line: if($boxes[$i]=='on') { to this if($boxes[$i]==$rs['username') { ?
-
open up notepad, and type this <?php echo "I need help"; ?> and save it as file.php, then upload it to a web server that has php installed, or install php
-
lol how is this PHP related? congratz
-
now it does not insert anything into the DB
-
now how do I remove the users that I did not select? If I did not select user1, but I selected user2 it inserts a blank for user1 and adds the value for user2? I have this so far: <?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']; if (empty($boxes)) { //somthing } $i=0; while ($i<=count($boxes)) { 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"); ?>
-
like this? <?php $arr = print_r($_POST); foreach ($arr as &$value) { mysql_query("insert into paid (user) values ('$value')"); } ?>
-
mike that loop did not work, how would I use the foreach?
-
when I select a few boxes I get this Array ( [checkbox] => Array ( [0] => GoogleBot [1] => admin ) [submit] => Mark Paid )
-
lol ya. If I could just learn how to handle checkboxes then I think I can get the rest
-
How do I handle checkboxes in PHP? Say I select 3 boxs out of 4, how do I get it to display those three checkboxs? here is my php code I have so far: (does not work) <?php if(isset($_POST['Submit'])) { for ($i=0; $i<count($_POST['checkbox']);$i++) { echo "<br />value $i = ".$_POST['checkbox'][$i]; } } ?> here is my html <?php include ("../../style/include/session.php"); include ("../../style/include/cons/head_2.php"); print '<div class="box"><h2>Select Paid</h2>'; if($session->isAdmin()){ ?> <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"); while ($rs=mysql_fetch_assoc($qr)) { ?> <tr> <td><? echo $rs['first'];?></td> <td><? echo $rs['last'];?></td> <td><input type="checkbox" name="checkbox[]" value="<?=$rs['username'] ?>" /> (<? 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"); ?> -Thanks!
-
no I want to be able to put a check be side their name, and then click submit, then it adds them to the paid table.
-
here is what I have so far: <?php $q = "SELECT user,first,last " ."FROM ".TBL_USERS.""; $user = mysql_result($result,$i,"user"); $fname = mysql_result($result,$i,"first"); $lname = mysql_result($result,$i,"last"); ?> <form name="form1" method="post" action=""> <table width="200" border="0"> <tr> <td width="103">First Name </td> <td width="87">Paid</td> </tr> <tr> <td><?php echo "$fname $lname"; ?></td> <td><label> <input type="<?php echo "$user"; ?>" name="checkbox" value="<?php echo "$user"; ?>"> </label></td> </tr> </table> <br> <label> <input type="submit" name="Submit" value="Submit"> </label> </form> <?php include ("../../style/include/session.php"); include ("../../style/include/cons/head_2.php"); print '<div class="box"><h2>Control Panel</h2>'; if($session->isAdmin()){ ?> <?php }else{ header("Location: ../../index.php"); } print '</div>'; include ("../../style/include/cons/foot.php"); ?>
-
ok how would I make a check list, where I can check off the user who has paid? I have been trying to make this part for the last 45mins now. any ideas?
-
oh yea I forgot
-
well I get this error now: what does it mean? here is my code <?php include ("style/include/session.php"); $q = mysql_query("Select * from tablename where user='$session->username'"); if(mysql_num_rows($q) ==0){ echo "Please Pay"; }else{ echo "You Paid!"; } ?>
-
would this work? <?php include ("style/include/session.php"); $q = "SELECT user FROM `paid` "; $r = mysql_query($q) or die(mysql_error()."<br /><br />".$q); if (function_exists($session->username){ echo "you have paid"; }else{ echo "you need to pay"; ?>
-
well I got to thinking, it might to make a table, with just the username then do a if exist statement, so if the username exist, it outputs "you have paid" otherwise "you need to pay" how would I do this?
-
I have a paid system for my website (I mean I want to make one) How would I write my if statement I have this so far, but I do not think it is correct: <?php include ("style/include/session.php"); $q = "Select count(*) as row_count from `paid`"; $r = mysql_query($q) or die(mysql_error()."<br /><br />".$q); if ($row['paid'] == ('yes')){ echo "Paid"; }else{ echo "Not Paid"; ?> How do I make it call it for each user individually this is what I use to define the user: $session->username any help?