Jump to content

joel24

Members
  • Posts

    760
  • Joined

  • Last visited

Everything posted by joel24

  1. use if ($selectedItem == 'value') { echo ' selected="selected" '; } put that line of code in each <option> tag and change the value for each option
  2. try echoing $_POST['EnglishWord'] and $_POST['EnglishDefinition'].. and also echo the query to check its all correct i.e. <?php /** PHP code inserted here */ $greekWord = $_POST['GreekWord']; $greekDef = $_POST['GreekDefinition']; $englishWord = $_POST['EnglishWord']; $englishDef = $_POST['EnglishDefinition']; $chapter = $_POST['chapter']; $section = $_POST['section']; //test to see if values being posted... echo $_POST['EnglishWord']; echo '<br />'; echo $_POST['EnglishDefinition']; echo "connection to the DB section of the code"; $conn = @mysql_connect("localhost", "root") or die("Could not connect to the data base"); $db = @mysql_select_db("test",$conn) or die("Error in selecting the data base."); echo "setting the SQL variables up"; // This is so the SQL statement is correctly formatted. $grkWrd = "'".$greekWord."'"; $grkDef = "'".$greekDef."'"; $engWrd = "'".$englishWord."'"; $engDef = "'".$englishDef."'"; $chptr = "'".$chapter."'"; $sctn = "'".$section."'"; echo "the query is here"; $query = "INSERT INTO word (GreekWord, GreekDefinition, EnglishWord, EnglishDefinition, Chapter, Sections) values ($grkWrd,$grkDef,$engWrd,$engDef,$chptr,$sctn)"; // echo query to validate echo '<br />'; echo $query; echo "exuctuing the query"; $exec = @mysql_query($query, $conn) or die ("Cannot add the word to the database"); echo "query execution successful"; if($exec) { //echo "<a href=\"javascript:history.back();\">Please go back and fill out the missing fields</a>"; echo "Word added"; //header("Location:http://localhost/ninjatuna/wordAdded.html"); } else { if($errmsg!="") { echo($errmsg); echo "<a href=\"javascript:history.back();\">Please go back and fill out the missing fields</a>"; exit; } } ?>
  3. maybe have a seperate column creationDate? and then you can determine if it was created before that quarter or if they just didnt' visit... another option would be to make the previous quarters NULL if a store is created after the first quarter.. i.e. if its made in the 3rd quarter, first and second quarter values would be NULL and the third would have a date..? i think my first suggestion is the most practical tho edit: rhodesa beat me to it! wrote too much to delete the post tho...
  4. you can split the string up into an array then reverse each element of the array then implode back into a string... $string = "this is a test string!"; $array = str_split($string, 2); foreach ($array as $key => $value) { $array[$key] = strrev($value); } //you can leave as an array or implode back into a string $string = implode($array);
  5. explode[2] would work alrite, or you could use some of the string functions and get rid of "kick user" leaving you the id... what are you trying to do here? might be an idea to store it in an array.. i.e. $test[1] = "kick user"; $test[2] = "userID"; ...?
  6. first up you have two form elements called 'email'... and you need to pass the URL on to the email script, so you need a hidden element with the url <input type="email" name="email" id="email" size="40"><p align="center"><label for="email"> <input type="submit" name="email" /> change to <input type="email" name="email" id="email" size="40"> <p align="center"><input type="submit" name="submit" /> <input type="hidden" name="url" value="'. $url2 . $url . $filename . '" /> make the form action go to say sendmail.php which would look like <?php if (isset($_POST['email'], $_POST['url']) && !empty($_POST['email']) && !empty($_POST['url'])) { $to = $_POST['email']; $url = $_POST['url']; $subject = 'File Upload URL'; $message = "Your URL is: $url"; $from = "youremail@yourdomain.com"; $headers = 'From: $from' . "\r\n" . 'Reply-To: $from' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $message, $headers); } //redirect user to whatever page header("location: index.php"); exit(); ?> obviously change the message / subject / from etc to whatever you want... and also make sure you change the index.php in the header/redirect to whatever page you want them to be forwarded to
  7. you can either change the ' to ", so that php parses all the variables within the quotations... or wherever the variable goes you can put it in like '.$variable.' i.e. 1 $message = "This is the email script: $variable etc etc"; i.e. 2 $message = 'This is the email script: '.$variable.' etc etc';
  8. @the eagle you wrote this? @seventheyejosh this is the same/similar to a mail script I have been using... have you had any troubles with it and gmail?
  9. your input code needs to be inside a form... i.e. <div class="wrapSearch"> <div> <form action="<?php echo basename($_SERVER['PHP_SELF']); ?>" method="post"> <input class="input" name="input" type="text" id="input1" size="30" maxlength="1000" onkeyup="autoSuggest(this.id, 'listWrap1', 'searchList1', 'input1', event);" onkeydown="keyBoardNav(event, this.id);" /> <input type="submit" name="search" id="search1" value="Search" /> </form> </div> <div class="listWrap" id="listWrap1"> <ul class="searchList" id="searchList1"> </ul> </div> </div> that form will post the contents to itself.. and the php will pick it up.. put the php in the very top of the page! before any <html> <head> etc if (isset($_POST['input']) && !empty($_POST['input']) { $userInput = $_POST['input']; //change spaces to - $userInput = str_replace(' ', '-', $userInput); //redirect user to url header("location: page/$userInput"); exit(); } that will redirect the user to www.mydomain.com/whatever/page/user-input what did you want to try and achieve from this?
  10. if you want the ability to decrypt/encrypt them, next time use mysql's AES_ENCRYPT() function. http://dev.mysql.com/doc/refman/5.1/en/encryption-functions.html
  11. if you had a form with text input called say userInputBox you could have $userInput = $_POST['userInputBox']; //change spaces to - $userInput = str_replace(' ', '-', $userInput); //redirect user to url header("location: page/$userInput"); exit();
  12. use this code to change the timezone... putenv('TZ=Australia/Sydney'); obviously change Australia/Sydney to whatever timezone a list of supported timezones is here http://au2.php.net/manual/en/timezones.php
  13. does your url have www.whatever.com?cat_id=whatever in it? you should probably also change it to if(isset($_GET['cat_id']) && $_GET['cat_id'] == $cat_id) {
  14. iframe's would take almost as much time as re-loading the entire page, and will require unnecessary PHP/MySQL calls when you can do it all instantly with jquery/javascript.... try this jquery plugin... its pretty simple you should get the hang of it http://tablesorter.com/docs/
  15. say you had a table called people: id, name, suburb, postcode, age and you were trying to find people in a suburb...? your form would have suburb: _______ [text input] order by: ______ [drop down with options: name, postcode, age -- must correspond to the SQL columns] then your php would be $suburb = $_POST['suburb']; $orderBy = $_POST['orderBy']; $sql = @mysql_query("SELECT * FROM people WHERE suburb = '$suburb' ORDER BY $orderBy"); or if you wanted more leniancy with teh search you could use LIKE... i.e. $sql = @mysql_query("SELECT * FROM people WHERE suburb LIKE '%$suburb%' ORDER BY $orderBy"); the %'s are wildcards...
  16. you should use $_GET / $_POST instead of $_REQUEST. I don't know exactly how the script works, but I'm guessing not all of the $_REQUEST elements are arrays - hence the second foreach is causing an error.. try if(is_array($_REQUEST)){ foreach ($_REQUEST as $sel){ if (is_array($sel) { foreach($sel as $sel_product => $id) { echo "Selected product:" . $sel_product. "<br>"; echo "Selected id:" . $id. "<br>"; } } } }
  17. got it working with the jquery 'live' function! thanks dj kat & thorpe
  18. how are the sales stored? in a database? are the sales online?
  19. use the window.onload function, so it only executes once the page is loaded. <script type="text/javascript"> window.onload = function() { alert('You have unread comments.'); }; </script>
  20. but if it were a file like 'bedroom.old.jpg', explode wouldn't work? well it would, but you'd only get 'bedroom' and not 'bedroom.old' you can use the pathinfo() function http://us3.php.net/manual/en/function.pathinfo.php $file = 'bedroom.jpg'; $filename = pathinfo($bedroom, PATHINFO_FILENAME);
  21. url = WHERE id =, none of the variables are being sent in the url? ... does your url look like whatever.php?id=X&url=Z&linkname=Y x, y and z are obviously the user input from the field. you should change the db query to the following in case the variables arent sent. //check if linkname, url and id are sent in the URL if (isset($_GET['linkname'], $_GET['url'], $_GET['id']) { $update = mysql_query("UPDATE nav SET linkname = " . $_GET['linkname'] . " , url = " . $_GET['url'] . " WHERE id = " . $_GET['id'] . ";"); }
  22. I have a page which allows users to edit rows in the table, When they click modify it uses a Jquery/javascript $.post function This posts to a PHP page which sends back a form. This all works fine, however, in the form I have a drop down menu where if certain values are selected I need different options to be shown/hidden - this works fine on elements that are on the page when it loads, but the jquery doesn't seem to recognize any of the elements in the retrieved form Take for example the following: HTML Page <html> <head> <script type="text/javascript"> jQuery(document).ready(function() { $('.editItem').click(function(event) { event.preventDefault(); $.post("test.php", {}, function(data) { if (data.length > 0) { $('#testDiv').html(data); } else { $('#testDiv').html("<div align='center'>Error retrieving item details</div>"); } }); }); //test function for testButton $('.testButton').click(function(event) { event.preventDefault(); alert('This test works!'); }); }); </script> </head> <body> <form id="test"> <button id="formRetrieval">Retrieve Form!</button> <button class="testButton">Test Function!</button> </form> <div id="testDiv"> </div> </body> </html> this is the php file the jquery posts to... test.php <?php //just a dummy script to echo the form echo '<form id="test"> <button class="testButton">Click me!</button> </form>'; ?> In the above, if I've typed it all correctly, only the first TestFunction button will display an alert (the one on the HTML page). When the 'Retrieve Form' button is clicked, it will load a new form into the testDiv and there will be a button with the same class 'testButton' (same as teh test function button), however, it will not display the alert. If I had written a function, say, showAlert() which showed an alert, and set the button to onclick="showAlert()" then it would work. In other words, the classes/id's of the elements which are being loaded through the PHP / post function aren't being identified... Hope this all makes sense, Any help would be greatly appreciated!
×
×
  • 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.