Jump to content

cyberRobot

Moderators
  • Posts

    3,145
  • Joined

  • Last visited

  • Days Won

    37

Everything posted by cyberRobot

  1. Are those the only four tests? For example, will blue ever appear by itself? If it does, do you still want to print to blue.txt? Also, where does the string come from? Could the following happen: $string = "Blue, Green, Yellow.."; $string = "Yellow..";
  2. To get your drop-down menu selection to stick, you'll need to utilize the passed selection. In the code that generates the drop down, run a simple to test to see which one is selected add the selected attribute. For example: <?php ... echo "<select name='photo_category' size='1'>"; while( $row = mysql_fetch_array( $result ) ) { echo "<option value=\"".$row['category_id']."\""; if($photo_category == $row['category_id']) { echo ' selected="selected"'; } echo ">".$row['category_name']."</option>"; } echo "</select>"; ... ?>
  3. You could use something like strpos() to figure out if the string contains the various colors. http://php.net/manual/en/function.strpos.php Then just create some if statements to write to the files: if(contains yellow) { write to yellow.txt } if(contains green) { write to green.txt } if(contains blue) { write to blue.txt }
  4. Good point, I was assuming that variable was populated by the program. If $searchfield contains data entered/selected by the user, make sure it's a valid choice.
  5. Depending on how your database is setup and how the images (and video/sound files) are named, you could look into using the other database fields to display the image. For example, if your database table contains the following fields: id: 1, name: Car id: 2, name: Dog And you have images like: Car1.jpg Dog2.jpg You could display the images using both the "name" and "id" field. <?php ... while($row = mysql_fetch_array($result)) { echo "<img src='imagesFolder/$row[name]$row[id].jpg'>"; } ... ?>
  6. If you're not doing so already, you should use the mysql_real_escape_string() on $search_term before querying the database. For more information, visit http://php.net/manual/en/function.mysql-real-escape-string.php
  7. I think gristoi is on the right track. When calling your poptastic() function, the URL argument needs to be surrounded by quotes. So you could use something like: echo "<a href='javascript:poptastic(\"".$t."\");'><img src='$i1' height='100' width='100'/></a> "; Or: echo "<a href='javascript:poptastic(\"$t\");'><img src='$i1' height='100' width='100'/></a> "; Note that I removed the dots from the second code example.
  8. That should work. Note that if you don't want to assign the modified string back to $_GET['name'], you could get rid of that part. $event = str_replace(".", " ", trim($_GET['name']));
  9. You would replace $str with $_GET['name']: $_GET['name'] = str_replace(" ", ".", trim($_GET['name'])); Note that the above code currently replaces all space characters with a dot. But if I'm reading your original post correctly it sounds like you want to go the other way. So the code would be changed to: $_GET['name'] = str_replace(".", " ", trim($_GET['name']));
  10. Is this for a WordPress website? If so, it looks like you can use the posts_nav_link() function to replace the next/previous post links with images. For more information, visit the Codex: http://codex.wordpress.org/Function_Reference/posts_nav_link
  11. Based on the code provided, the if test is only going to execute once. If you want it to execute every time the while loops, you'll need to modify the code: <?php $count = 0; while ($row = mysql_fetch_assoc($Ships4)){ if ($count < $row_dclasscorella['Dclass4_totla']){ ... } } ?>
  12. First, you're missing the end curly bracket in the JavaScript: <script type="text/javascript"> function showfield(activeDropDown) { ... } </script> Also, the onchange attribute will never get activated if the drop-down doesn't contain more than just the "Other..." option. You'll need to add more options to the School drop-down for the code to work. Before I get in trouble, it turns out that I didn't write the code in the above post. I was just correcting code written by the OP.
  13. If you don't want to use jQuery, I've posted JavaScript code to a similar request here: http://www.phpfreaks.com/forums/index.php?topic=331574.msg1560437#msg1560437
  14. Uh oh, if you start using jQuery, you might need to change your signature.
  15. If I understand the issue correctly, it sounds like you're having problems with losing data in the second form; the one that displays the drop-down menu. If that's the case, you need to create hidden variables for whatever you want to pass through the form. For example: <input type="hidden" name="initialy" value="<?php echo $_POST['initialy']; ?>" /> Also, I would strongly recommend that you avoid using $_SERVER['PHP_SELF'] in your form action attribute. It's very easy to hack PHP_SELF when it's used in the action attribute, in links, or when it's displayed on screen. http://www.mc2design.com/blog/php_self-safe-alternatives
  16. I'm sure there's a more efficient way, but you could get the extension by exploding the filename with the dot '.' <?php $file_parts = explode('.', $image); $temp = count($file_parts) - 1; $ext = $file_parts[$temp]; ?> Note there are some security issues to work on before going live. First you want to look into dealing with visitors who pretend to upload an image, but are actually uploading something like a PHP script and naming it "image.php.jpg" or "ScriptToDoSomethingBad.php". You'll also want to use mysql_real_escape_string() before saving the image name (and other information) to the database. Otherwise someone could modify/access you're database using SQL injections. http://php.net/manual/en/function.mysql-real-escape-string.php
  17. Instead of potentially creating hundreds of PHP files that essentially do the same thing, wouldn't it be better to store all the picture references in a database? Then just use templates/pictures.php page to display them all based on a id. That way if the initial template ever changes, you would only need to modify one file.
  18. cyberRobot

    links

    Note that if you want the named anchor reference (#asd) to work, you'll need to add a named anchor near the <div> tag. <div id="asd"><a name="asd"></a> Hi there </div> If you add the named anchor it will jump to the newly shown content. If you don't want the page to jump to the new content the #asd isn't needed. You could just have the href attribute set to "123.html".
  19. As xyph said, you would explode the string based on whatever's between the different error messages. Of course, if you're using the space character you should consider changing it to something else. Preferable something that's not commonly used in the error messages such as the straight bar "|". You could also use multiple characters such as ":|:".
  20. cyberRobot

    links

    It sounds like you're trying to hide content so that visitors won't see it until they click a link. If that's correct, you'll need to use something like JavaScript. The following tutorial may help: http://www.cssnewbie.com/showhide-content-css-javascript/ On the other hand, if you're just looking to jump to the text after a link is clicked, you could look into named anchors: http://www.google.com/search?q=html+named+anchors
  21. Isn't it because you're exploding the error string based on the space character? <?php $errors = explode(" ", $errors_string); ?>
  22. It seems like the logic behind the function should be modified. Instead of calling the function again to test the data you just read, why not test the data right away? Maybe switch it to: <?php function findEndTag($file, $line, $consolidatedLine) { $fileContent = file($file); foreach ($fileContent as $i => $lineArray) { if ($lineArray == $line) { $consolidatedLine = $consolidatedLine." ".$fileContent[$i+1]; $endTagFound = strstr($consolidatedLine,"/>"); if (!$endTagFound) { return (findEndTag($file, $fileContent[$i+1], $consolidatedLine)); } else { return $consolidatedLine; } } } } ?>
  23. What does your code look like so far?
  24. What do you mean by being able to access their account? Do they just see the page as if logged in or are they able to interact and do stuff with their account?
  25. You could do something like: ... <select name="satisfied"> <option value="yes"<?php if($_POST['satisfied'] == 'yes') { echo ' selected="selected"'; } ?>> yes </option> <option value="no"<?php if($_POST['satisfied'] == 'no') { echo ' selected="selected"'; } ?>> no </option> </select> ... Also, you should avoid using $_SERVER['PHP_SELF'] in forms for security reasons. For more info, see: http://www.mc2design.com/blog/php_self-safe-alternatives
×
×
  • 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.