Jump to content

GingerRobot

Staff Alumni
  • Posts

    4,082
  • Joined

  • Last visited

Everything posted by GingerRobot

  1. Well im going to presume that you have some sort of field which identifies the the different user groups. Lets call it `usertype` for the sake of it. You can then cycle through the results, finding the numbers of each group type and the staff and member's names. <?php $mysql2 = "SELECT * FROM forumusers ORDER BY id DESC LIMIT 1"; $result2=mysql_query($mysql2); $staff = array(); $members = array(); $num_staff = 0; $num_members = 0; $num_guests = 0; $num_hidden = 0; foreach($row = mysql_fetch_assoc($result2)){ $usertype = $row['usertype']; $username = $row['username'];//also assuming you have some field for the username $hidden = $row['hidden'];//and perhaps a separate field for their hidden status if($usertype == "staff" && $hidden != 'hidden'){//this may be a number representing staff rather than the text staff $staff[] = $username; $num_staff++; }elseif($usertype == "member" && $hidden != 'hidden'){ $members[] = $username; $num_members++; } //you get the picture } ?> You would then have the numbers stored in the variables $num_staff etc, and the staff names stored in the array $staff and the members stored in the array $members.
  2. You really wont help your chances of getting a response by posting comments like that. People are not obliged to help you.
  3. Personally im still at a loss to understand what you are asking. Are you saying you want to add a new field to your database table? Are you saying that, presently, you get the exact text "$player, $score" entered into your database, rather than the values of those variables(for example, you might expect "player 1, 100" to be entered)?
  4. Dont think its really what you're after, but you could set up apache to parse files with .gif extensions as php files. Wouldn't really be a gif file, but yeah. I was messing around with it because i wanted a dynamic picture on my myspace - and they wont allow images with .php extensions.
  5. Im a little confused - dont you want to be deleting their email from the table rather than adding it to another?
  6. I dont see how that can be possible. All the php is executed on the server. It should have nothing to do with the browser.
  7. I think this sort of depends on what your question is. If you are wanting to submit a form when, for example, a value is selected from a dropdown box, then yes, your solution is in javascript. If you are wanting to send form data to another website, perhaps if a certain condition is met, then you should look into the uses of curl and php.
  8. Well, this looks amazingly similar to this question: http://www.phpfreaks.com/forums/index.php/topic,146021 To which i've provided a solution at the bottom.
  9. I think you need to echo: selected='selected' Rather than just 'selected'
  10. You can just check the message variable in the $_GET array: <?php if($_GET['message'] == "User+name+and+password+not+found"){ echo "Sorry! Username and/or password have not been found!"; } ?>
  11. Im really not sure what your asking - it looks to me like you've answered your own question.
  12. Redarrow - im pretty sure ive read find that using count() is faster than mysql_num_rows. jbrill - yes, we'll need to see the form really. Otherwise we'd just be guessing.
  13. Yes, thats exactly the way to go: <?php $sql = "SELECT count(*) FROM `yourtable` WHERE `category`='$current_category` AND `subcategory`='$current_subcat' AND `featured`='1'"; $result = mysql_query($sql) or die(mysql_error()); $num = mysql_result($result,0,"count(*)"); if($num <= 2){ //can add a featured product }else{ //cant add a featured product } ?>
  14. Whoops, that was partly my fault. Glad you sorted it out
  15. I think you're almost there. However, you'll need to make some other changed to be able to edit more than one row at a time. You'll need all of your form inputs as arrays, and its usually best to make them have a key which is the ID from the database: <form name="form1" method="post" action="<?PHP $_SERVER['PHP_SELF'] ?>"> <table width="665" cellpadding="0" cellspacing="0" class="main"><tr bordercolor="#909090" bgcolor="#909090"> <?php include '../db.php'; $query = "SELECT DISTINCT sym, id, e_date, e_price FROM tablename ORDER by sym"; $result = mysql_query($query); $count = mysql_num_rows($result); while($row = mysql_fetch_array($result)) { ?> <tr> <td><div align="center"><input name="checkbox[<?php echo $row['id'];?>]" id="checkbox[<?php echo $row['id'];?>]" type="checkbox" value="<? echo $row['id']; ?>"></div></td> <td><input type="text" name="new_sym[<?php echo $row['id'];?>]" id="new_sym" value="<? echo $row['sym']; ?>"></td> <td><input type="text" name="new_e_date[<?php echo $row['id'];?>]" id="new_e_date" value="<? echo $row['e_date']; ?>"</td> <td><input type="text" name="new_e_price[<?php echo $row['id'];?>]" id="new_e_price" value="<? echo $row['e_price']; ?>"></td> <td><A href="notes.php">View/Edit Notes on this Record</A></td> <td> </td> <td><input type="submit" name="update" value="Edit Selected"></td> </tr> <?php } if($_POST['update']) { $new_sym=$_POST['new_sym']; $new_e_date=$_POST['new_e_date']; $new_e_price=$_POST['new_e_price']; $checked = $_POST['checked']; foreach($checked as $key => $value){ $id= $key; $sql = "UPDATE symbols SET sym='$new_sym[$id]', e_date='$new_e_date[$id]', e_price='$new_e_price[$id]' WHERE id='$id'"; $result = mysql_query($sql) or die(mysql_error()."<br />SQL: $sql"); } // if successful redirect to records.php if($result){ echo "<meta http-equiv=\"refresh\" content=\"0;URL=records.php\">"; } } mysql_close(); ?> Ive also changed your loop to a foreach - that way it'll only loop through if the checkbox was selected
  16. Yep. Thats possibly the shortest answer ive given on these forums
  17. If you pass along the page the current user is on to your navigation.html page (which you'll need to make a .php page) you can have a differant class on the current page. So you will include like: <?php include("http://www.yoursite.com/navigation.php?curr_page=about"); //whoops - forgot you'll need to use an absolute path otherwise you cant sent along get data ?> Then, in your navigation page: <?php $pages = array("home","about","contact");//put all the possible pages into an array - far easier $curr_page = $_GET['curr_page']; foreach($pages as $value){ echo "<li"; if($value == $curr_page){ echo " class='currentpage'"; } echo "><a href='".$value.".php'>$value</a></li>"; } ?>
  18. Poco, you forgot to close any of the table rows
  19. Err, well if you used a foreach statement on the $_GET array, you could grab all the keys. I would think this would be a fairly big security risk though: <?php foreach($_GET as $key => $value){ echo $key.'<br />'; } ?>
  20. If you mean you want to have 5 results on a line, then a new line etc, then take a look at this post: http://www.phpfreaks.com/forums/index.php/topic,95426.0.html
  21. Well, on the face of it, there is no differance. However, i believe that echoing the HTML will be slower, as php has to parse the entire string for variables etc. Wether or not there is any differance in speed and server usage between echoing something in single quotes(php does not parse this, hence why you cannot echo variables inside single quotes) and exiting php and typing your HTML, ive no idea. As for what i do, if its mainly html that im displaying, ill exit from php - saves worrying about escaping quotes etc, whereas if what im displaying is fairly short, and has lots of variables in it, then ill stay in php and echo. Seems easiest this way to me. Just personal preference though.
  22. I think you're after: if(empty($street)){ }
  23. I took a look at the website - god knows what the whole comment thing they are doing is. Apparently they are trying to mix php comments with HTML. You CAN comment in html: <!--comment here --> Although, of course, someone can see these comments by viewing the source. As far as php is concerned, a user cannot see anything that is being parsed by php. They can only see what is sent to the browser. As for your second question, its all a matter of how you store the passwords etc, and making sure you validate users properly. If you, for example, stored all of the passwords for a user in a text file that was accessible from the web, then it would be vulnerable. If you stored the passwords as variables in a php file, or in a database, then the storage is not vulnerable. You must also remember to check all data provided by the user, incase there are any nasty people out there trying to gain access to your system without authorization.
  24. Just wanted to add, this is only if magic_quotes are turned on. Personally, i hate the magic_quotes concept. Don't see why something should happen to data from the user that i don't do to it.
×
×
  • 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.