Jump to content

Alex

Staff Alumni
  • Posts

    2,467
  • Joined

  • Last visited

Everything posted by Alex

  1. Create a variable initialized at 1, then increment it every loop. Something like this: <?php $i = 1; while($row = mysql_fetch_array($result)) { echo '<tr>'; echo '<td>'; echo $i; echo '</td>'; echo '<td>'; echo '<form name=view method=get action=viewprofile.php>'; echo "<input type=hidden name=username value="; echo $row['username']; echo "/>"; echo "<a href=viewprofile.php?username="; echo $row['username']; echo ">"; echo $row['username']; echo "</a></td></form>"; echo '<td>'; echo $row['score']; echo '</td>'; echo '</tr>'; ++$i; } ?>
  2. Don't bump threads this old. Instead, make a new thread, in the miscellaneous forum in your case.
  3. This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=337280.0
  4. This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=337055.0
  5. ".jpg" is 4 characters. Nevertheless, you can achieve this using substr (check the manual). if(substr($str, -4) == ".jpg")) { // ... }
  6. You have a lot of superfluous code there. To solve your issue with the spaces you can use trim $tags = array_map('mysql_real_escape_string', array_map('trim', explode(',', $_POST['tags']))); $getPonitTagId = mysql_query("SELECT * FROM tags WHERE tag_name IN('".implode("','", $tags)."')") or die(mysql_error()); I also added some security using mysql_real_escape_string array_map
  7. Uh... that's what AJAX is. AJAX is JavaScript which sends requests to the back end. The back end sends a response back to the JavaScript. The JavaScript then inserts the response into the current page in real time. Yes, i know AJAX is capable of doing what I described. but I'd definitely like to know if anyone here know how to do the same thing with php? AJAX uses PHP (or some other server-side language). I don't think you know what AJAX is.
  8. You have an extra two "" now. $email_message = "In ".$city . " in the month of " . $month.$year." you observed the following weather: \n"; If that fails, you're still not telling us the error. And you're still not using [[tt][/tt]code] tags.
  9. I don't think the exercise was fun specifically because it involved a game.
  10. It looks like you're trying to append to the string using the .= operator without the string being defined beforehand. If so, you should change that to just $email_message = ...
  11. Of course! The parameter that header takes is a string. So you should check the PHP manual for how to manipulate strings. In this case what you want to do is concatenate, or combine, your string and the variable. Here's how you would do it: if ($_GET['query']=="google") header( 'Location: redir.php?query=' . $_GET['query'] ); As you can see, a period, ., is the concatenation operator. Alternatively, if ($_GET['query']=="google") header( "Location: redir.php?query={$_GET['query']}" ); Oh, and for the future if you're going to be posting code please use [[/tt]code] or [[tt]php] tags, it makes it much easier to read. I've edited your post for you this time.
  12. Please use [[/tt]code] or [[tt]php] tags to post code in the future. Is that exactly how the code appears in your file? Your PHP tags are all messed up. You shouldn't have a "<?php" when you're already inside of a PHP tag. Similarly, you houldn't be using "?>" if you're not intending to get out of PHP. If that's not your problem, what exactly are the errors you're getting?
  13. This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=336868.0
  14. Those tags are called bbcode (bulletin board code). You can find plenty of PHP scripts for parsing bbcode online. There's even a PECL package for it. I'd suggest googling "PHP bbcode parser" or something similar.
  15. I agree, I was thinking the same thing. I think it would be fun and great way to learn from each other and could ultimately lead to a nice library of examples.
  16. Technically, I posted code and it's not working as I intended. I described what I'd like my code to be able to do and instead of just helping and explaining so everyone can learn you're just turning people away from the idea. What exactly have you contributed in this thread besides basically telling people to figure out how on their own? I'm not looking to get into a semantics debate, or any other type of debate for that matter, with you. Your code demonstrated that you didn't try very hard to resolve this on your own, and it wasn't even very germane to your question in general. My intention wasn't to stifle your learning, quite the contrary: You can find much more information regarding your query on google than I would ever be able to personal provide you with in this thread. Instead of arguing with me why don't you just take the advice and realize that you can find countless resources to learn what you're after, and without having to wait for someone to reply. Programmers have to be very resourceful, "Google it" is probably the best advice I can offer.
  17. Oh, your issue is with sessions? Great! There are even more tutorials on how to use sessions, so yes, I am telling you to Google it. This is a PHP code help forum, and you're not having any issue with your code. If you want to learn about sessions then use one of the many tutorials made for that, don't come here and ask a question like that.
  18. This is the sort of thing that you should be able to find tons of tutorials online for, and judging from your first post I don't think you've done much research on your own about this, or sessions for that matter. Try Googling for some tutorials and come back here to asks questions if you run into coding problems.
  19. When posting code please use [[/tt]php] or [[tt]code] tags. Here's an example, along with an explanation, of how to do what it seems like you're after. <?php // start the session session_start(); // check to see if the session variable, $_SESSION['visits'], exists. // $_SESSION['visits'] will be an array containing timestamps of the visits in this session if(!isset($_SESSION['visits'])) { // if this variable isn't set yet.. then we want to set it, and we'll store the current timestamp as the first element $_SESSION['visits'] = array(time()); echo "This is your first visit!"; } else { // $_SESSION['visits'] already exists, so they've visited in this session before // first, we'll print out all the previous visits foreach($_SESSION['visits'] as $visit) { echo date("D, d F Y - G:i:s", $visit); } // now, we'll add this visit's time stamp to the array $_SESSION['visits'][] = time(); }
  20. Do you already have user system then?
  21. Firstly, you need to put session_start at the top of any page you wish to use sessions on (read the manual). I'm not really sure what you're trying to do when you say: Can you elaborate?
  22. Are you sure you want to check E: and not D:?
  23. array_search returns the key, so in your case it's returning 0, which evaluates to false. You need to use !== operator. if($key !== false) { }
  24. I edited my post, but you quoted me before that. I was actually talking about something else: I thought that you permanently increased the attack stat of the ninja, but upon closer inspection of your code I realized that you didn't, so I removed my comment about that. But what you posted on was another good point. The specifications are too ambiguous.
  25. Yeah, sorry, when I said "In which case a change in stats during the battle wouldn't matter." I meant with respect to determining who goes first. I wasn't ever arguing with that. edit: Nevermind.
×
×
  • 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.