Jump to content

wisewood

Members
  • Posts

    226
  • Joined

  • Last visited

    Never

Everything posted by wisewood

  1. <a href=# onClick="window.print();">Print this page</a> Try adding that to thte page you want to print.
  2. is the field that you're trying to reset to "NULL" a numeric field such as an integer? If it expects an integer, and you tell it to use NULL, it will use 0 instead.
  3. Learn the basics and start building a custom script for yourself. plenty of tutorials around to get you started, and plenty of people here who will help you on the way.
  4. $query = "select users.rep_name, rep_table.rep_name, rep_table.rep_id, customer_table.* from customer_table, rep_table, users where users.rep_name=rep_table.rep_name and customer_table.rep_id=rep_table.rep_id and account_no=1564"; cant see any reason for it not to work. have you tried using it as above to make sure it works right using static data, and not variables. it might be the variable giving you grief.
  5. looks like you're on the right lines anyway. Your method does the same as mine.
  6. Run this code as is, and you'll see what it does. Any more help you might need, just yell. [code] <?php $needle = "£"; $string = "If it costs £252.62 to buy something that should cost £300.00, you've bagged yourself a bargain and got it for £47.38 cheaper than it should have been."; echo "<b>Original String:</b><br>$string<br><br>"; $number_of_occurances = substr_count("$string", "$needle"); echo "$needle appears $number_of_occurances times.<br><br>"; $count = 0; while ($count<$number_of_occurances) { $string = substr($string, strpos("$string", "$needle")+1); echo "$string<br><br>";         $count++; } ?> [/code]
  7. Type: <select name="select_accom"> <option value='Villa'>Villa</option> <option value='Caravan'>Caravan</option> <option value='Lodge'>Lodge</option> </select> &nbsp; Board: <select name="select_board"> <option value='Full Board'>Full Board</option> <option value='Half Board'>Half Board</option> <option value='B & B'>B & B</option> <option value='Self-Catering'>Self-Catering</option> </select> &nbsp; using this will ensure your options are passed properly... otherwise the board would have over-written the type. If you want your code fixed properly, you'll have to give us the whole code.
  8. your select names must be different. <SELECT NAME="accom_type"><option value="caravan"><option value="villa"></select> <SELECT NAME="accom_board"><option value="half board"><option value="full board"></select> hope this helps
  9. ok, thats a bit more complex and i'll have to test my code. I will go and run some tests and try and loop through a longer string and see if i can exctract them all. brb
  10. I hope that person is fictional, otherwise he just had his personal details splattered all over the internet. Try this: [code] $query = "SELECT users.rep_name, rep_table.rep_name, rep_table.rep_id, customer_table.* FROM customer_table, rep_table, users WHERE users.rep_name = rep_table.rep_name AND customer_table.rep_id = rep_table.rep_id AND account_no LIKE '$_GET[keywords]'"; [/code]
  11. As a very rough example... This will display the values of first_name, last_name and address fetched from a database table. When you click submit, it will send the updated information to you_update_script.php, which will then use a mysql UPDATE to set the new values to the appropriate record. If you need further explaination, let me know. <code] <?php // Connect to your database // Get the details of the record that you want to edit ?> <FORM METHOD="post" ACTION="your_update_script.php"> <INPUT TYPE="text" NAME="first_name" VALUE="<?php echo '$first_name'; ?>"><br> <INPUT TYPE="text" NAME="last_name" VALUE="<?php echo '$last_name'; ?>"><br> <TEXTAREA NAME="address" COLS="35" ROWS="6"><?php echo '$address'; ?><br> </FORM> [/code]
  12. does it just not display the image, or does it display the X image not exist icon? ie, is it that your if/else doesnt work, or that there is an error in your code within the if/else
  13. Set the $needle variable to whatever you're looking for in the string. $haystack should be replaced with whatever the variable of your string is. This will return $needle_location as position of the needle in the haystack. From there, you can use a substr() function to chop down the haystack into a chuck appropriate for what you want. [code] $needle = "£"; $needle_location = strpos($haystack, $needle); [/code]
  14. do you have a timestamp in the table where your scores are kept, or even better, an auto-increment integer field used as the primary key? If you have an auto-increment (we'll call this 'IDfield') do this; $query = mysql_query("SELECT * FROM `arcade` WHERE `game_id`='$game_id' ORDER BY score, IDfield DESC"); This will select the scores highest to lowest, but will display them in order of when they were entered into the database table, rather grouping them by username.
  15. firstly, search.php needs to be modified so that session_start() is the first thing in the page. PS. you might wanna remove your username & password details from your code that you're sharing with the world.
  16. Started reading the code, first thing i thought of as i read it... Are there 10000 entries in the table?
  17. just curious, but why use the # instead of the ? anyway
  18. with the version of phpmyadmin that i'm using... this is what i'd do; 1. Login to phpmyadmin 2. Select the database 3. Click the Export link at the top of the page 4. Select all the tables in the list that i want to backup 5. Ensure Structure AND Data are selected 6. Click Go. This will give you the mysql data which you can copy and then paste into phpmyadmin's SQL query box on the new host. Hope this helps.
  19. $_SESSION['variable_name'] = "This is my variable"; If you have performed all the tasks you need to, you can use session_destroy(); to kill the session, or you can delete individual session variables by using unset($_SESSION[variable_name]); If you are going to use sessions, you need to have session_start(); AT THE TOP of your document, before anything else. so your document would start something like; <?php session_start(); // some php stuff ?> <HTML> <HEAD> etc etc.
  20. The code you have below is setting the session variables correctly... however i dont see where the $first_name, $last_name, $email_address, $user_level & $username variables are coming from. [code]         // Register some session variables!                  $_SESSION['first_name'] = $first_name;                  $_SESSION['last_name'] = $last_name;                  $_SESSION['email_address'] = $email_address;                $_SESSION['user_level'] = $user_level;                  $_SESSION['username'] = $username; [/code] oh... i think i might have it. ($login_check > 0){ while($row = mysql_fetch_array($sql)){ foreach( $row AS $key => $val ){ $$key = stripslashes( $val ); you have $$key instead of $key.
  21. Ignore the bit below, i didnt read your question properly. You are correct. [ignore] other way around. $_SESSION[username] = $_POST[username]; the session username is to be the same as the post username. Not the other way around. If you set it the wrong way around, you will be setting the other variable with the value of the session, which hasnt been assigned yet, so its empty. [/ignore] And yes, you need to set <?php session_start(); ?> RIGHT AT THE TOP of your document, before you put any HTML tags in at all.
  22. This will help you on your way. I found this when trying to do the same thing. If you set a variable to contain the value of selfURL(); you will then be able to use substr to get whatever is after the #. [code] <?php function selfURL() { $s = empty($_SERVER["HTTPS"]) ? ''   : ($_SERVER["HTTPS"] == "on") ? "s"   : ""; $protocol = strleft(strtolower($_SERVER["SERVER_PROTOCOL"]), "/").$s; $port = ($_SERVER["SERVER_PORT"] == "80") ? ""   : (":".$_SERVER["SERVER_PORT"]); return $protocol."://".$_SERVER['SERVER_NAME'].$port.$_SERVER['REQUEST_URI']; } function strleft($s1, $s2) { return substr($s1, 0, strpos($s1, $s2)); } ?> [/code]
  23. in the code calling the sessions (2nd lot of code you posted) you should use; echo "$_SESSION[username]"; when using echo "$username"; it is calling the $username value from your db.php include file. Once you've set a session variable and left the page where the original variable was, you'll have to use the $_SESSION[variable_name] method to call it in for use. Hope this clears things up for you.
  24. Best idea i came up with so far was to use a <div> along with ajax, which submits the data to the php script via an xml http request, and then hides the div which contains the form. As the form data is sent via an image onClick event, without actually pressing "submit" refreshing the page doesnt generate the problem you described, it just presents you with an empty form again. I can't give you an example of the code though, as its not on my PC here at work, its at home.
×
×
  • 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.