Jump to content

JamesB

Members
  • Posts

    425
  • Joined

  • Last visited

Everything posted by JamesB

  1. echo '<select>';$result = mysqli_query( "select dept_code from table" );while ($row = mysqli_fetch_array($result)){echo '<option>'.$row['dept_code'].'</option>';}echo '</select>'; for question 2, if you want to use that query: select dept_name from table where dept_id = 1 you will need to use ajax to send a request to php, and have php reply with the single dept name. alternatively you could avoid ajax by sending all dept names to the client before the form is submitted.
  2. to check if a key exists in the array: if (isset($devices['samsung'])){} or to check if a value exists in the array: if (in_array('Samsung', $devices)){} also for the include path, you need to use 2 backslashes for each one. C:\\xampp\\.. (doesn't apply to forward slashes)
  3. one option would be to use: echo empty($rows[0]['name']) ? '' : $rows[0]['name']; or you could create array elements with blank values initially: $fieldCount = 5;for ($i=0; $i<$fieldCount; $i++) { $rows[$i] = array( 'name' => '' );} but i think calling a function with the first option would be better.
  4. to load all returned sql rows into an array: $sql = "select * from person where ###### = 'male' ";$result = mysql_query($sql); $rows = array();while ($row = mysql_fetch_array($result)) { $rows[] = $row;} then to read the array: echo $rows[0]['name'];echo $rows[0]['age'];
  5. post_max_size should be more than upload_max_filesize, as the post data is the entire file(s) + extra datahttp://uk3.php.net/m...i.post-max-sizehttp://uk3.php.net/m...ad-max-filesize
  6. you need to also specify the key for each value used in the data variable, eg. var data = {firstname: 'something-here',lastname: 'something-here-2'};
  7. hmm it works fine for me with 3 keys held down in firefox, chrome and opera.
  8. xmlhttp.onreadystatechange=function(){if (xmlhttp.readyState==4 && xmlhttp.status==200){window.globalVariableName = xmlhttp.responseText;}}; function someOtherFunction() {confirm(window.globalVariableName);}
  9. to fix the shape from being centered to the mouse position, you could store the mouse-to-shape xy position offsets: function startMove() {$('.movable').on('mousemove', function(event) {var thisX = event.pageX + offsets.x,thisY = event.pageY + offsets.y; $('.movable').offset({left: thisX,top: thisY});});}$("#containerDiv").on('mousedown', function(event) {$(this).addClass('movable');offsets = {x: $(this).offset().left - event.pageX,y: $(this).offset().top - event.pageY};startMove();}).on('mouseup', function() {$(this).removeClass('movable');}); also check here for the cursor icon:http://stackoverflow...-with-css-or-js
  10. JamesB

    Help please

    It's probably meaning to remove any characters which are not these: A-Z a-z 0-9 . @You could loop around all characters in the email string, then if the character is valid, push the character on to the end of another string for the "cleaned" email.
  11. escape_data() isn't taking $data by reference
  12. try this: document.body.style.background="url('"+cols[day]+"')"; you could also store the month image urls in an array instead of using 12 parameters: var monthImages = [ '1.jpg', '2.jpg', ..];var url = monthImages[ day ];
  13. name=\"favorite1\"should bename=\"food\" andvalue=\"favorite1\"should bevalue=\"$favorite1\" in: echo "<input type=\"radio\" name=\"favorite1\" value=\"favorite1\"> $favorite1\n"; the empty <select> is because of: <select name = "food" id = "food"> and </select> for validating the color and food you can use in_array() as birbal said.http://php.net/manua...on.in-array.php you could put the $color and $food arrays in 1 file, then include that file from your current 2 files (to save duplicating them)http://php.net/manua...ion.include.php
  14. also, for an associative array, you'll probably want the arrays looking like: $color = array( 'Red' => true, 'Blue' => true, ...); (where the keys are strings)
  15. JamesB

    logout procedure

    if someone logs in, then they find out they have a virus or something on their computer, they might want to logout hoping it will force the hacker to relogin with username and password.if the logout didn't remove the server side token, the hacker would then still be able to send the token to the server directly and the server would find the token in the database and think the hacker is logged in, despite the real user clicking logout. if you were limited to removing the token from either the client or the server, it would be better to remove it from the server. (but remove it from all places when possible)
  16. i think it's currently getting evaluated as UPDATE images SET title = ('$title' AND category = '$style') WHERE id = '$image_id' try using a comma instead of AND to update multiple cells.
  17. you could use a function to fetch the checked radio element, then access it's value with .value <input type="button" value="Submit" onclick="sendVote()" /> function getCheckedRadio(name) { var radios = document.getElementsByName(name); for (var i=0, j=radios.length; i<j; i++) if (radios[i].checked) return radios[i]; return false;} function sendVote() { var radio = getCheckedRadio('vote'); // <input type=radio name=vote> if (radio == false) alert('no radio checked!'); else alert(radio.value);}
  18. that sounds like apache is running but php isn't.
  19. try changing $Start to $inc in: While ($Start <= $End) { as $inc is the variable being changed inside the loop.
  20. to get the value of the selected <option>: <select name="optionList" id="optionList" onchange="copy(this);" > function copy(select) { var value = select.options[select.selectedIndex].value; alert(value);}
  21. this code: $style_id = $row['id']; comes before $row is assigned a value. also this: if ( $category LIKE %$style_id% ) the LIKE and %'s are part of SQL, not PHP, they need to go in the query string sent to mysql_query.
  22. <html><head><script type="text/javascript">function onClickTrue() { console.log('clicked true'); alert('clicked true');}function onClickFalse() { window.close();}</script></head><body><div class="question"><h1>What is Your Name?</h1></div><div class="trueans" onclick='onClickTrue()'><h3>Owais</h3></div><div class="falseans" onclick='onClickFalse()'><h3>Zeeshan</h3></div><div class="falseans" onclick="onClickFalse()"><h3>Samad</h3></div><div class="falseans" onclick="onClickFalse()"><h3>Shehrose</h3></div></body></html>
  23. http://www.w3schools...bj_location.asp use location.href for the full url, instead of location.pathname.
  24. you need quotes around n in the callback parameter: '.. onkeypress="keyE(event,\'' + n + '\',this.value)" />';
×
×
  • Create New...