-
Posts
3,145 -
Joined
-
Last visited
-
Days Won
37
Everything posted by cyberRobot
-
Add class to parent div based on image being landscape or portrait
cyberRobot replied to erme's topic in Javascript Help
Could you provide a little more information by what you mean by "it doesn't work"? Also, it might help to show more code. Are you importing a jQuery library? For what it's worth, the following code works for me: <html> <head> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function() { $(".img_wrapper").each(function(){ var img = $(".img_wrapper img"); var div = $(".img_wrapper"); if (img.height() < img.width()){ div.addClass('landscape'); } else { div.addClass('portrait'); } }); }); </script> </head> <body> <div class="img_wrapper"><img src="myImage.jpg" width="225" height="500" /></div> </body> </html> -
Add class to parent div based on image being landscape or portrait
cyberRobot replied to erme's topic in Javascript Help
Note that you won't be able to access the <div> and <img> tags until the page fully loads. Is your code behind an "onload" event? Since you're using jQuery, perhaps the following will help: http://api.jquery.com/ready/ -
Have you looked into how functions work? http://www.php.net/manual/en/functions.user-defined.php
-
For what it's worth, the code would be more efficient if you used an elseif. Also note that I used isset() to make sure the "subscribe" variable is set before performing the test. <?php // evaluate the answer if(isset($_POST['subscribe']) && $_POST['subscribe'] == 'Yes') { header('Location: http://www.webdissemble.com/yes.php'); exit; } elseif(isset($_POST['subscribe']) && $_POST['subscribe'] == 'No') { header('Location: http://www.webdissemble.com/no.php'); exit; } ?> You could also simplify the code as follows: <?php // evaluate the answer if(isset($_POST['subscribe'])) { if($_POST['subscribe'] == 'Yes') { header('Location: http://www.webdissemble.com/yes.php'); exit; } elseif($_POST['subscribe'] == 'No') { header('Location: http://www.webdissemble.com/no.php'); exit; } } ?> Note that I marked the topic as solved. If you need further assistance, please mark it as unsolved or start a new topic.
-
You might want to review the basics of PHP here: http://php.net/manual/en/language.variables.basics.php Also, information on the $_SERVER variable can be found here: http://php.net/manual/en/reserved.variables.server.php
-
For whatever reason the SQL query is just broken into multiple string and connected with the concatenation operator: http://php.net/manual/en/language.operators.string.php To simplify the first query, it could be written as: <?php $sql = "INSERT INTO tutorials_tbl (tutorial_title,tutorial_author, submission_date) VALUES ('$tutorial_title','$tutorial_author','$submission_date')"; ?>
-
Did you try using the suggestions made here: http://forums.phpfreaks.com/topic/282282-add-edit-delete-script-problems/
-
Have you considered CSS? https://www.google.com/search?q=css+forms+styling
- 3 replies
-
- jquery
- checkboxes
-
(and 1 more)
Tagged with:
-
Sorry, I'm not sure what you're asking. Is the form not being re-populated after the submit button is clicked? Is there a problem with the email message being sent? Or are you having problems with the error messages not displaying as expected? Side note: I would recommend checking out the following article with regard to using PHP_SELF as the form action: http://seancoates.com/blogs/xss-woes Also, please surround code blocks with tags in the future. They improve the readability of your posts.
-
Did you see my other question?
-
You don't see anything when adding the following line of code? <?php echo $reply->content; ?> If it outputs something, what is the exact text? Also, I just noticed that there are two similar variables. Which one should we be focusing on? <p><?php echo stripslashes(nl2br($post->content)); ?></p> <p><?php echo stripslashes(nl2br($reply->content)); ?></p>
-
Have you tried displaying the $reply->content variable as is (without nl2br, etc.)? What do you get in the source code?
-
echo a message on reaching 0 on jquery countdown timer?
cyberRobot replied to crf1121359's topic in PHP Coding Help
Unless I'm missing something, you're looking to replace the JavaScript which handles the count-down portion that happens after the page loads. Once the page loads, you're dealing with client-side interactions. That's where JavaScript comes in. As far as I'm aware, there isn't a way to do what you're asking without something like JavaScript. You might be able to minimize the amount of JavaScript being utilized with Ajax. But keep in mind that Ajax is JavaScript and can be turned off. -
echo a message on reaching 0 on jquery countdown timer?
cyberRobot replied to crf1121359's topic in PHP Coding Help
And this works with JavaScript disabled? Also, where is $end_date defined? -
Basically, the POST variables aren't set yet. You could fix it by doing something like <?php //... $ambtenaarnummer = (isset($_POST['ambtenaarnummer'])) ? $_POST['ambtenaarnummer'] : ''; //... ?> Of course, you'll need to fix the other variables. :-)
-
echo a message on reaching 0 on jquery countdown timer?
cyberRobot replied to crf1121359's topic in PHP Coding Help
PHP code is executed on the server. What you're trying to do needs to happen on the client side. To perform client-side interaction, you'll need to stick with a client-side solution like JavaScript. -
It helps to know what those warnings are so we can help. I would imagine that you're seeing errors like the following: Also note that you're outputting something to the screen before using the header() function here: <?php //... echo "Saved!"; header("Location: index.php"); //... ?>
-
The header() function needs to be called before any output to the screen. The following quote is from the PHP manual (http://php.net/manual/en/function.header.php):
-
I have marked the topic as solved. If you need further assistance, please mark it as unsolved...or start a new thread.
-
You can use the same technique that you're using with the hidden fields. Just remember to add "echo". The "echo" was needed before $i below: <input type="hidden" name="emp_id<?php echo $i; ?>" value="<?php echo $row[0]; ?>"> Note that you could also use array syntax. The $id below would correspond to the employee's ID in the database. That way you can quickly associate the text-box entry with an employee. <input type="text" name="TextboxNameHere[<?php echo $id; ?>]" size="2" style="text-align:right;">
-
Unless you're planning to use the POST variables for something other than the query, you could reassign the escaped value to the same variable. Otherwise, PHP needs to maintain two variables. Also, you need to escape all of the POST variables before running the queries. <?php //PREPARE POST DATA FOR QUERY $_POST['title'] = mysql_real_escape_string($_POST['title']); $_POST['name'] = mysql_real_escape_string($_POST['name']); $_POST['email'] = mysql_real_escape_string($_POST['email']); //... escape the rest here ?> Note that the filter_var() function can be used to validate the email address. Example 1 in the link below shows how to check email addresses: http://php.net/manual/en/function.filter-var.php
-
@priyankagound - This is essentially the same thing I suggested in Reply 2. As indicated in Reply 3, the OP isn't interested in hiding the cells. Also, please surround code with tags.
-
Could you copy and paste the applicable code inside the forum message? Please surround the code with tags to make it easier to read.
-
@mcwee93 - Which API are you using to connect with MySQL (MySQL, PDO, or MySQLi)? Side note: mysql_ functions have been depreciated. At some point in the near future, you'll need to look into the alternatives. More information can be found here: http://www.php.net/manual/en/mysqlinfo.api.choosing.php
-
There are two print_r() statements which are generating the output. <?php print_r($sizeArray); //<-- shows an array print_r($sizeArraySORTED); //<-- shows "1" ?>