Jump to content

Alex

Staff Alumni
  • Posts

    2,467
  • Joined

  • Last visited

Everything posted by Alex

  1. Alex

    Loop

    Edit: Is it really necessary to use those classes? If not you can just use: $result = mysql_query('SELECT id, title FROM table LIMIT 10'); while($row = mysql_fetch_assoc($result)) { echo '<p><a href="/page/?item=' . $row['id'] . '">' . $row['title'] . '</a></p>'; }
  2. Thanks, I thought about that a little later that I was foolish because I didn't test it with more than one '>' in the text. And figured out why I was wrong, just too lazy to edit my post. Thanks for the help; I'm trying to get better at regex.
  3. Here's what you can do, JavaScript will work. var form_submitted = false; function submit_form () { if (form_submitted) { alert("Your form has already been submitted. Please wait..."); return false; } else { form_submitted = true; return true; } } Then within your <form> element add onsubmit="return submit_form()"
  4. Use JavaScript. Yea, but technically he said "AND changing the info to black in the DB". So if you use server-side validation they're not submitting and updating the DB
  5. Within your php file that processes the information do something like.. if(!empty($_POST['name'])) { //Update the DB } else { echo 'You didn\'t enter a name.'; }
  6. You can try something different like this: <?php $colors = array('blue', 'red', 'green', 'purple', 'orange', 'brown', 'gray'); for($i = 0;$i < count($author_quotes);$i++) { $color = $colors[$i%7]; echo '<blockquote class="' . $color . '">' . $author_quotes[$i] . '</blockquote>'; } ?>
  7. Find out how off that time is compared to what you want. Then just set an off set based on that. Say it's 1 hour ahead of what you want, you'd do: echo date("l dS of F Y h:i:s A", time()-3600);
  8. Not sure I quote understand. There's an array $author_quotes, you want to display all the quotes once in a different color class? Or what?
  9. Try setting the file that's making the file (This one) to 777.
  10. You have to change your CHMOD file attribute values. So you give that file permissions.
  11. The syntax you have is a bit off. foreach($author_quotes as $quote) { echo '<blockquote class="">' . $quote . '</blockquote>'; //Is that where you want the quote? }
  12. Maybe you want $_SERVER['REQUEST_URI']; ?
  13. Do you mean $_SERVER['PHP_SELF']; ? But when i use echo $_SERVER['PHP_SELF']; it didn't return anything? It should, it will return the directory/file in terms of the root folder. <?php echo $_SERVER['PHP_SELF']; ?>
  14. Kind of an ugly date format, for doing something like this a UNIX time stamp would be preferred. But you can do something like: $part = explode(' ', $row['time']) $day = explode('-', $part[0]); if($day[2] + 5 >= date("j")) { //Can edit } else { //can't }
  15. Do you mean $_SERVER['PHP_SELF']; ?
  16. Why do you need to set anything to true or false?.. All you need to do is put the code I gave you inside your submit button: eg. <input type="submit" onclick="what I gave you..." /> And it'll do exactly what you want.
  17. Makes sense, this runs from the button as opposed to the head and is more compact. How do I capture the value from return whether it be TRUE/FALSE or is 'return' the variable that I can use? A JM, That's all you need. Put that inside your Submit button element. Once submit is clicked you'll be asked that question, if you hit "Ok" It'll submit the form. If you hit "Cancel" It won't.
  18. You do something like.. onclick="if(confirm('Are you sure? This is irreversible!')){return true;}else{return false;}" Makes this easier.
  19. Yup, it makes sure that the values for the $_GET array are in your array of valid values.
  20. If it just has http://domain.com/username besides using PHP to get the variable they're most likely using mod-rewrite to modify the URL. A normal url would look like http:/www.domain.com/somefile.php?variablename=value . Then in PHP to get that varaible you'd do: $variable = $_GET['variablename']; So in your example, www.domain.com/username, mod rewrite would be used and basically change the way the server sees that URL, most likely 'hiding' something like username=, allowing www.domain.com/?username=username to just be domain.com/username
  21. Edit: Whoops, my mistake... Read the manual: http://us3.php.net/manual/en/function.include.php
  22. Adsense doesn't know if it was generated by php, or hard-coded into the file. Because there really is no difference. They're both output to the browser in html. AdSense however does take some time to get information and won't always display relevant ads right away. There are also many tips which you can find online to helping it work even more in your favor.
  23. $used = Array(); while($row = db_fetch_array($results)) { $tempLetter = substr($row['products_description'], 0, 1); if(!in_array($tempLetter, $used)) { $used[] = $tempLetter; echo '<a href="' . link_url(PAGENAME_PRODUCTS_DESCRIP, 'part_number=' . $row['part_number']) . '">'.$tempLetter.'</a>'; } } echo '</div>';
  24. CRON jobs is a way to automatically run a script every X about of time. Check to see if your host has CRON jobs, if not there are some external CRON programs (try googling ezcron-lite) which do it for you simply by telling it how often to run a script, and it's location.
  25. http://acmeous.blogspot.com/2009/02/how-to-enable-curl-support-for-php-in.html
×
×
  • 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.