Jump to content

AE117

Members
  • Posts

    83
  • Joined

  • Last visited

    Never

Posts posted by AE117

  1. I have an array I would like to search that is being built from a data base as follows

    $result = mysql_query("SELECT id_one, id_two FROM accounts LIMIT 60");
    
    while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
    
        printf("ID_ONE: %s   ID_TWO: %s", $row[0], $row[1]);  
    echo "<br>";
    }
    
    

     

    What I would like to do is after the array is created echo out a certain row from that array.

    Soi if the array looks like this

     

    key  id_one  id_two

    1        458      444

    2          468      455

    3        467        466

     

    I can search the array for 468 and it would return 455

     

    Thanks  I will be posting back if I find any new information my self.

  2. That is exactly what I am try to prevent. I dont want to have to call multiple queries to get a set of results. so if the results is to call the to a table

     

    id      color

     

    1  green

    2  red

    3  green

     

    and get all the green items. I want to be able to store them in an array and then call from that array the results i need. So in this case the array should hold

    key  id    color

    [1]    1    green

    [2]    3    green

     

    then i can call key 2 which would give me the values under that. I just dont know how to do it. I am still looking into it but it appears that arrays and a push statement is on the right track

  3. I have been looking into this and I can find a definite answer.

     

    I was wondering if i call a query

     

    $query = mysql_query("SELECT * FROM table_name")

    $rows = mysql_fetch_assoc($query)

    which returns 50 results

     

    can I call and echo a certain result. Lets say I want to echo result number 5 of the 50.

     

    I have no idea how to go about this so I was just hoping someone could lead me in the right direction.

  4. Figured it out

     

    HTML:

    <textarea name="description[<?php echo "2"; ?>]" id="description[]" cols="" rows="" style="width:300px;">Content Here</textarea>

     

    PHP:

    foreach ($_REQUEST['description'] as $key=>$checkbox)
    {
    echo $key;
    echo "<br />";
    echo $checkbox;	
    }

  5. I have this.

     

    <input name="delete[]" type="checkbox" id="delete" value="1" />

     

    What I want to is get the value from this which is the "1"

    AND

    Get the id which would be "delete"

     

    I can get the value but i cant seem to get the id

     

    This is what I have been using

    foreach($_REQUEST['delete'] as $index=>$val){
    echo $index;
    echo $val;
    }
    

     

    echo $index just gives me the num of array I am on and the $val gives the actually value. Can anyone help me out with getting the id or how I can specify a id.

     

    THanks

     

     

     

  6. First let me ask you this. Do You want everyone to know who the email is sent to. When sending an email you can cc people which mean they get a copy but all recipients can see each other. I which case you would just modify your php mail header to have a cc: value.

     

    If you are want to just send emails to a list of people that looks like it was just sent to them then a do while loop is what you are looking for.

  7. Im not new to php but I am trying to think if this possible.

     

    I want to write a php script that creates a div inside a div until lets say 10 divs are created.

     

    I have been trying do while statements but them seem to place them underneth each other not within.

     

    I want

    <div id=one">

    <div id=two">

    <div id=three">

    </div>

    </div>

    </div>

     

    Only thing I can create is

     

    <div id=one"></div>

     

    <div id=two"></div>

     

    <div id=three"></div>

     

    Like I said  I dont even know if this is possible or if I am just retarded and can't think of a way to do it but it would be nice to see what others have to say about it.

  8. JavaScript is executed in the client's browser, so that's hardly putting any stress on your server.

     

    But the decryption process would, unless your using something like unescape, which because even more pointless.

  9. I think its a good idea...

     

    On my page I access the javascript file for the page to use

     

    <script src="" you know the rest.

     

    if you follow that url you can see the javascript file and the way it is written. Wouldnt it be better to have it encrypted so users can't see whats there?

     

     

  10. I have never encrypted JavaScript before but I would like to start, I think its a good Idea.

     

    I'v been searching the internet to figure out how an encryption script works and I cant seem to get any of them to work. Can someone help me out with the process.

     

    1 - I take my script and use there decodes and then put that encoded sscript into my file. Then my javascript in that file doesnt work anymore.

     

    Do I have to include a path to a decoder or whats going on??

  11. Thanks alot  jdavidbakr you pointed me in the right direction and allowed me to get the information I needed.

     

    Here is the code that will do what I am talking about which is given a url show the images from that page. If you still dont understand when you run the code you will

     

    <?php
    
    $url = "http://www.domain.com/";
    $baseurl = preg_replace("/[^\/]+$/","",$url);
    $page = file_get_contents($url);
    $parts = explode("<",$page);
    $images = array();
    foreach($parts as $part){
    if(preg_match("/img/",$part)){
    $part = preg_replace("/^img.+src=\"([^\"]+)\".+$/m","$1",$part);
    if(!preg_match("/http:/",$part)){
    $part = preg_replace("/^\//","",$part);
    $part = $baseurl . $part;
    }
    $images[] = $part;
    }
    }
    
    foreach($images as $img){
    print '<img src="'.$img.'">';
    }
    
    ?>
    

     

    Dealing with relative or absolute is another issue but its a great start  Once again thanks.

  12. You're wanting to do some sort of a screen scraper, then?  Not overly trivial, but I think what you'll want to do is load the html of the page into a variable with file_get_contents() and run preg_match() to extract all the images with a regular expression.  You'll then need to check those images to see if you need to pepend the directory you're pulling the html from, just the domain (if the src tag starts with "/"), or keep it as is.

     

    I think I get what your saying I will give it a shot and see how it works and let you all know

  13. Thats not what I am talking about.

     

    There is no way to know where the images are stored on any given website url, let alone know the name.

     

    Pretty much I want to be able to insert a Url into a textfeild hit submit then I want a php script to go to through the url given, so go to that website and find all the images that are wrapped in the img tag and then display them on my website with out downloading them.

     

    I know its hard but I also know is possible....

     

    Once again any help is appreciated I will update this when I get closer or atleast hit the road.

  14. foreach($_SESSION['items'] as $cat_id)

    {     

          $query = "SELECT * FROM products WHERE productnumber='$_GET[productnumber]'";

    }

     

    maybe...

    $query = "SELECT * FROM products WHERE productnumber='$cat_id'";

     

    I am having a hard time following the way you write code so I apologize if im wrong I will keep looking at it to see if i come up with anything else

  15. Here you go I will give you the code first and then explain what I did

    
    <html>
    
    <head>
    
    <script type="text/javascript">
            function getHTTPObject(){
                    if (window.ActiveXObject)
                            return new ActiveXObject("Microsoft.XMLHTTP");
                    else if (window.XMLHttpRequest)
                            return new XMLHttpRequest();
                    else {
                            alert("Your browser does not support AJAX.");
                            return null;
                    }
            }
    
            function doWork(value){
                    httpObject = getHTTPObject();
    
                    if (httpObject != null){
    
                            httpObject.open("GET", "test.php?keyword="+value, true);
    					alert ("working");
                            httpObject.onreadystatechange = setOutput;
    
    						document.getElementById("output").innerHTML = value;
    
                    }
            }
    
          function setOutput(){
                    if (httpObject.readyState == 4){
                            alert("Ready state does equal 4");
                            document.getElementById('output').innerHTML
                                    = httpObject.responseText;
                    }
            }
    </script>
    
    </head>
    
    <body>
    <form name="keywordform">
    Search: <input type='text' name='keyword' onkeyup="doWork(this.value);" id ="1" />
    </form>
    <div id='output'>blank</div>
    </body>
    
    </html>
    

     

    I think what you where going for was to change the bottom area to the text being typed. You dont actaully need to send out a request to a page. So i told the function doWork when called to get this.vale. Which means the element that it is on. If you wanted another element you could call it using the getElementby and so on.

     

    The function doWork(value) value is now set to the this.value so it is now like a var

     

    there is no real reason to open and document but i left that there just for kicks. As you can see it show working the it gets the document but the id output and changes the innerHtml to the Value which is called in the doWork(value)

     

    the rest of the code is useless let me know if this is what you where looking for or if you need more help

     

     

     

     

     

  16. Here is what I am looking for.

     

    Facebook has this feature where when you put in a website url Example: www.mydomain.com  it will ask you to choose an image from that website.

     

    I want to do a similar thing, Have user input a url then show all the images from the url.

     

    Can anyone point me in the right way I have been looking for hours on google and the php manual and have come up with nothing. Thanks

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