Jump to content

james909

Members
  • Posts

    60
  • Joined

  • Last visited

Posts posted by james909

  1. How to a check if a php variable value is one of the following characters: A to J, or ,k to t, (ie.: A B C D E F G H I J k l m n o p q r s t)

     

    I tried:

    if (preg_match[A-Jk-t], $checkChar) 
    {   
    // do this
    }
     
    But it did not work  :-\
  2. thanks for the replys,

     

    all is good now

     

    I uploaded using filezilla, and it was set to 'auto' changed it to 'binary' and it displays the image

     

    i needed to do this as the script i am using requires, i could of worked through the script changing it, but now i am all the wiser and have another string to my coding bow :)

     

    should now always keep filezilla in binary mode?

  3. My site currently uses one parameter in the URL like this:

     

    http://www.mydomain.com/folder/?paramname=AB32123

     

    I would like to remove the parameter name, so the URL is:

     

    http://www.mydomain.com/folder/?AB32123

     

    How would I then call use this parameter,

    currently I use $_GET['paramname'] but without a name I am unsure how

     

    I have tried:

    $_GET

    $_GET[]

     

    but they both through up errors?

     

    what is the correct way to get this paramter without a name

  4. I have the following Javascript code on a HTML page, it is a popup window to the main parent window.

     

    When the user selects a picture in this child window it changes the variable and a picture in the parent window.

     

    I have pages changepic1.html and changepic2.html. 

     

    This is the code for changepic2.html which doesn't work, yet changepic1.html which works is exactly the except the 2s in in the lines commented on are 1s. 

    <!DOCTYPE html>
    <html lang="en">
    <head>
    
    <meta charset="utf-8">
    
    <title>Select Image</title>
    
    <link rel="stylesheet"  href="select.css">
    
    <script>
    (function() {
       'use strict';
    
    function removeWindow(){
    
    if(window.name=='wxyz'){
      var pic=document.getElementById('thumbs').getElementsByTagName('img');
      var c=pic.length;
    
    while(--c>-1) {
    pic[c].onclick=function(){
     
       var nsrc=this.src;
    
       var nme=nme.replace(nme.substr(nme.lastIndexOf('.')),'');
    
       window.opener.document.getElementById('change2input').value=nme;  // the Id is ('change1input') in other page 
       window.opener.document.getElementById('c2-pic').src=nsrc;   // the Id is ('c1-pic') in other page
       window.opener.document.getElementById('c2-pic').style.display ='inline';  // the Id is ('c1-pic') in other page
       if (nme=='Clear') { window.opener.document.getElementById('c2-pic').style.display ='none'; } // the Id is ('c1-pic') in other page
       window.close();
      } 
     }
    
      var txt=document.createTextNode('close this window'); 
      var cl=document.createElement('h2');
          cl.setAttribute('id','wincl');
          cl.appendChild(txt);
    
      document.body.appendChild(cl);
    
    document.getElementById('wincl').onclick=function(){ window.close(); }
      }
     }
       window.addEventListener?
       window.addEventListener('load',removeWindow,false):
       window.attachEvent('onload',removeWindow);
             function closeme()
        {  
            window.close();
        }
        window.onblur=closeme;
    })();
    </script>
    
    </head>
    <body>
    
    <ul id="thumbs">
    
     <li><img src="redGround-1.png" ></li>
     <li><img src="yellowFlat-2.png" ></li>
     <li><img src="bigCurve-3.png" ></li>
     <li><img src="smallCurve-4.png" ></li>
     
    </body>
    

    change1input and change2input are hidden input fields in the parent window and both exist.

     

    c1-pic and c2-pic are the div ids of the image to change in the parent window.

     

    This window doesn't close when the image is clicked, but the other page works fine.

     

     

    I can't understand why the page that changes pic 1 works but this page that changes pic 2 doesn't, when they have the exact same code?

  5.  

    Here is my Code, It is a popup to change an image main window, I am trying to get the image to display if image 2,3 or 4 are selected, and no image to display is image 1 is selected. It all works except getting the If statement to check whether image 1 is selected or not:



    <!DOCTYPE html>
    <html lang="en">
    <head>


    <meta charset="utf-8">


    <title>Select an Armor</title>


    <link rel="stylesheet"  href="selectwindow.css">


    <script>
    (function() {
       'use strict';


    function removeWindow(){


    if(window.name='wxyz'){
      var pic=document.getElementById('thumbs').getElementsByTagName('img');
      var c=pic.length;


    while(--c>-1) {
    pic[c].onclick=function(){
       window.opener.document.getElementById('windowc').src=this.src.replace('-thumb','');
       window.opener.document.getElementById('windowc').style.display="inline"; 
       if(pic.src=="pics/Image1.png") { window.opener.document.getElementById('a1windowchange').style.display="none"; }
       window.close();
      }
     }


      var txt=document.createTextNode('close this window'); 
      var cl=document.createElement('h2');
          cl.setAttribute('id','wincl');
          cl.appendChild(txt);


      document.body.appendChild(cl);


    document.getElementById('wincl').onclick=function(){
       window.close();
       }
      }
     }
       window.addEventListener?
       window.addEventListener('load',removeWindow,false):
       window.attachEvent('onload',removeWindow);
       function closeme()
        {  
            window.close();
        }
        window.onblur=closeme;
    })();
    </script>


    </head>
    <body>


    <ul id="thumbs">
     <li><img src="pics/Image1.png" alt=""></li>
     <li><img src="pics/Image2.png" alt=""></li>
     <li><img src="pics/Image3.png" alt=""></li>
     <li><img src="pics/Image4.png" alt=""></li>
    </ul>


    </body>


    What is the correct way to code: if(pic.src=="pics/Image1.png")

     

    To check whether pics/Image1.png has been selected or not?

  6. When I click an image I am trying to get another window to open (500px by 500px) which can be scrolled down, that sits on top of the current browser screen, which displays multiple images (that are 50px by 50px), when one of these images is clicked it sets a javascript global variable in the current browser screen as that image name, and changes the image that was originally clicked in the current browser to the new image.

     

    Can anyone supply any sample code of how I would achieve this

  7. Here is my code inside a function():

     

    for (var i=1; i<6; i++) 
             {
    for (var j=1; j<11; j++) 
               {
               if (h" + i + "w" + j" == "t") {
               var build = "Bulk"; }
               if (h" + i + "w" + j" == "z") {
               var build = "Master"; }
               if (h" + i + "w" + j" == "T") {
               var build = "Storage"; }
               parambuild = parambuild+build; 
               } 
             }
    

    I am atempting to get check what letters globally declared vars: h1w1, h1w2, h1w3, h1w4 .... etc .... to h5w10 contain

     

    and then make a string such as: BulkMasterBulkBulkStorageBulk

     

    But in the current code the string contains: undefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedun......

     
  8.  
    I am trying to declare javascript variables from php array values using a loop.
     
    Trying to declare javascript var h1 as php array value from $array[1][h], and h2 as $array[2][h], and h3 as $array[3][h],and so on...
     
    Here is my code:
    <SCRIPT LANGUAGE="JavaScript">
    
    for (var i=0;i<61;i++)
    {
    var h[i] = "<?php echo $array[i][h] ?>";
    var hl[i] = "<?php echo $array[i][hl] ?>";
    var hs[i] = "<?php echo $array[i][hs] ?>";
    } 
    
    </script>

     When I <script type="text/javascript"> document.write(h1); </script> it is blank

     

  9. I have the following Javascript that changes the images on screen as the dropdown menu chages:

    Javascript

    Code:
    function hullchangeimage()
    {
    if (!document.images)
    return
    document.images.hullpicture.src=
    document.hullgallery.changehull.options[document.hullgallery.changehull.selectedIndex].value
    }

    HTML Dropdown Menu:

    Code:
    <form name="hullgallery">
    <select name="changehull" size="1" onChange="hullchangeimage()">
    <OPTION value="Hull1">Hull1</option>
    <OPTION value="Hull2">Hull2</option>
    <OPTION value="Hull3">Hull3</option>
    </select>
    </form>

    HTML image SRC:

    Code:
    <img class="hullbuild" src="build_pics/Hull1.png" name="hullpicture" width="500" height="250">

    Problem is: this makes the picture the value of the select box, which for example is "Hull2", but the image scr is "build_pics/Hull2.png", so how do I add .png to the end of the value, and the folder infront, in the javascript. I can't change the values in the select options by adding .png as the value are needed for another function that requires just the value.

  10. I am getting an error trying to get a for loop to work when looping through an array:

    for ($a=1; $a<6; $a++)
    {
    $setuplength++;
    for ($b=1; $b<7; $b++)
    {
    $fleetarray[$a][w$b] = $matches[0][$setuplength+5];
    }
    
    }
    The code [w$b] is throwing up an error, I am try to assign the array values [w1], [w2], [w3], [w4], [w5], [w6] as it goes through the loop, but it is not letting me get the number from $b to use inside the array value.
     
    What is the correct way to code this?
  11. I have the following alpha-numeric example string

    $string = "1AJ4dH4c2bRfa6";

    which I want my php to split upto in the following array, into 1 characters, unless the character is a lower case a,b,c or d then i want the following character to be added to that array value:

    stringarray[1] = "1";
    stringarray[2] = "A";
    stringarray[3] = "J";
    stringarray[4] = "4";
    stringarray[5] = "dH";
    stringarray[6] = "4";
    stringarray[7] = "c2";
    stringarray[8] = "bR";
    stringarray[9] = "f";
    stringarray[10] = "a6";

    The string that needs splitting up could be longer or shorter than this example.

     

    I have tried string split, but this can only split the string into array value lengths of 1 or 2, not how I want:

    $stringarray = str_split($string, 1);
    $stringarray = str_split($string, 2);

    What is the code for: if the charater is aphanumeric (1-0 A-Z a-z) I need the it to be split into an array value of 1 character, with the exception of if the character is lower case a, b, c or d then the next character needs to be added to that array value.

  12. hi, i am hoping someone here can help me with this javascript coding, on a html5 send form, i have been searching and googling to no luck in finding a way or the coding to do this.

     

    i am trying to find the javascript to validate whether 4 client entered numeric fields are equal to or less than a number (between 0 and 12), all other entered values and letters etc i want to throw up an error message asking to re-enter.

     

    here is my html form, and the inputs:

    <form name="htmlform" enctype="multipart/form-data" method="post" action="base_submit_form.php" onsubmit="return validateForm(this);"
     onreset="return confirm('Are you sure that you want to reset this form?');">
    
    <label for="submit_username">Username (max length 15): </label>
    <input  type="text" name="submit_username" maxlength="15" size="30" required><br />
    <br />
    Number of Each Rooms:<br />
    <input  type="number" name="livingrooms" min="0" max="10" maxlength="2" size="1">Living Rooms<br />
    <input  type="number" name="diningrooms" min="0" max="10" maxlength="2" size="1">Dining Rooms<br />
    <input  type="number" name="kitchens" min="0" max="10" maxlength="2" size="1">Kitchens<br />
    <input  type="number" name="beedrooms" min="0" max="10" maxlength="2" size="1">Bedrooms<br />
    
    <input type="submit" value="Submit">  <input type="reset" value="Reset!">
    </form>
    

    here is the current javascript for verifying a username has been entered:

    <script defer type="text/javascript">
    function validateForm(formElement)
    {
    	if( document.htmlform.submit_username.value == "" )
       {
         alert( "Please Enter a Username." );
         document.htmlform.submit_username.focus() ;
         return false;
       }
    }
    

    how to i code the javascript validation to check the total numbers of living rooms, dining rooms, kitchens, bedrooms is a number between 0 and 12? adding all the different rooms together, ie. 1 living rooms, 3 dining rooms, 2 kitchens, 4 bedrooms (total 10 is fine), but 3 living rooms, 3 dining rooms, 5 kitchens, 4 bedrooms, will put up the error popup?

  13. it is only returning the first  mysql row in the results,

    like this:

    Array ( [id] => 1 [image_type] => jpg [total_ratings] => 17 [average_rating] => 8.6 )

     

     

     

    how do i get the results to be a multi-dimensional array

    like this:

    Array ( [1] => Array(  [id] => 1 [image_type] => jpg [total_ratings] => 17 [average_rating] => 8.6 )  

    [2] => Array(  [id] => 2 [image_type] => jpeg [total_ratings] => 10 [average_rating] => 7.2 )

    [3] => Array(  [id] => 3 [image_type] => png [total_ratings] => 8 [average_rating] => 9.3 )

    [4] => Array(  [id] => 4 [image_type] => jpg [total_ratings] => 12 [average_rating] => 5.2 )

    [5] => Array(  [id] => 5 [image_type] => png [total_ratings] => 15 [average_rating] => 8.1 ))

     

    so that all 5 rows from the results are displayed

  14. i am trying to getting the results from mysql database 'userdatabase' where the user_type column match and is_approved field is 1.

     

    i am trying to get the top 5 rows with the highest average_ratings.

     

    here is my code:

    $mysqli = new mysqli("localhost", "levelDbUser", "honey", "levelDb");
    $outpostlevel = (int) $array[user_type];
        $sql = "SELECT id, image_type, total_ratings, average_rating FROM userdatabase WHERE user_type = ? && is_approved = 1 ORDER by average_rating ASC LIMIT 5";
        $statement = $mysqli->prepare($sql);
        $statement->bind_param("i", $outpostlevel);
        $statement->execute();
    	$statement->bind_result($id, $image_type, $total_ratings, $average_rating);
        $statement->store_result();
        while ($statement->fetch()) {
    	$topoutposts = array(
    		'id' 			  => $id,
    		'image_type'	  => $image_type,
    	    'total_ratings'	  => $total_ratings,
    		'average_rating'  => $average_rating
    	    );
        }
    print_r ($topoutposts);	 

    but the print_r array is returning nothing (blank)

×
×
  • 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.