Results 1 to 5 of 5

Thread: PHP method to import multiple values

  1. #1
    Join Date
    Jan 2010
    Posts
    46

    PHP method to import multiple values

    I want to scroll through a photo gallery with titles etc. I would like to use DHTML and AJAX so I created an AJAX request to my php script. I would like to import multiple values and therefore my php array is an array of table. What is the method to import multiple values in PHP?

  2. #2
    Join Date
    Nov 2008
    Posts
    1,022

    Re: PHP method to import multiple values

    The first point is provide a few more details. What is the current structure of your page (the code would help!)? What is already in place? What is the intended operation (user actions etc..)? What do you not understand "import multiple values and my base"? What is the volume (number of photos)?

  3. #3
    Join Date
    Jan 2010
    Posts
    46

    Re: PHP method to import multiple values

    A gallery can count a hundred photos and the site may have several user gallery alone is me. My Ajax code
    Code:
    <script type="text/javascript">
    var xmlhttp = false;
    if (window.ActiveXObject) {
       xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    else if (window.XMLHttpRequest) {
       xmlhttp = new XMLHttpRequest();
       xmlhttp.overrideMimeType('text/xml');
    }
    function exReq(){
       //var state = document.forms[0].elements[0].value;
       //var url = 'ajax.php?state='// + state;
       xmlhttp.open('GET','ajax.php',true);
       xmlhttp.onreadystatechange = writeResponse;
       xmlhttp.send(null);
    }
    function writeResponse() {
    str1="";
    str2="";
    str3="";
    var state=xmlhttp.status;
    //clearTimeout(newtimer);
    switch (xmlhttp.readyState){
    case(2):var call1 = setTimeout(str1=rqSent(state),5000);
    //clearTimeout(call1);
    case(3):var call2 = setTimeout(str2=waitRq(state),5000);
    //clearTimeout(call2);
    case(4):var call3 = setTimeout(str3=response(state),5000);
    alert(typeof(str3));
    break;
    } 
    var myid = document.getElementById('display');
        myid.innerHTML=str3;	
    //clearTimeout(call3);}
    }
    function rqSent(state){
    var str1 ="request sent status is :"+state;
    return str1;
    }
    function waitRq(state){
    var str2 ="Response being received...the status is :"+state;
    return str2
    } 
    function response(state){
    var str3 ="Response is :"+xmlhttp.responseText+" the status is :"+state;	
    return str3
    }
    function init(){
    exReq();
    }
    newtimer = setTimeout("init()",6000);
    </script>
    <body>
    <div id="display"></div>
    </body>
    My php code in php4
    I pass in php5 but now they're acting to a query quickly

    PHP Code:
    <?php
    require ("Connect.php");
     
    function 
    recupDatabase(){
    $connection mysql_pconnect (SERVER,NAME,PASSWORD);
     
    if (! 
    $connection)
    {
     echo
    "Sorry, connection to " SERVER." impossible\n";
     exit;
    }
     
    if (! 
    mysql_select_db (BASE,$connection))
    {
     echo 
    "Sorry, access to basic " BASE " impossible\n";
    }
     
    $sql "SELECT * FROM `gallery`";
    $req mysql_query($sql) or die('<u>SQL Problem</u> : '.$sql.'<br>'.mysql_error
    ());  
     
    $num_rows mysql_num_rows($req);
     
    while(
    $result mysql_fetch_array($req)) {
    $nametrack[] = $result['track'];
    $headline[] = $result['headline'];
    $title[] =  $result['title'];
    $image[] = $result['image'];
    $name[] = $result['name'];
    $miniature[] = $result['miniature'];
    $numphotoclick[] = $result['numphotoclick'];
    }
    $database = array($nametrack,$headline,$title,$image,$name,$miniature,$numphotoclick);   
    return 
    $database;
    }
    recupDatabase();
    ?>
    An echo database sends a string that is "array" and who is not an array
    transmits a return "nothing"

    My goal is simply to import my database and its data fields so their values
    in a JavaScript table. Then I manipulate the data via Ajax client side on the table. The goal is to limit the requests. I intend to use nicknames in JavaScript and class methods and make an application independent as possible from the server. Ajax becomes a kind of Applet

  4. #4
    Join Date
    Nov 2008
    Posts
    1,022

    Re: PHP method to import multiple values

    OK. While the main concern is: Why to use Ajax?

    If it is to "import everything" and then manage the set (Slideshow) entirely in JavaScript, why not integrate everything to your page in its original generation? You would gain in execution time and simplicity ...

    I spoke to load all url images (what appears to your script) and not the images themselves ...

  5. #5
    Join Date
    Jan 2010
    Posts
    46

    Re: PHP method to import multiple values

    This is obviously what do my original script. I load urls course but as I scroll through the images without scrolling pages created dynamically through php when inserting images via the backoffice I have to use DHTML and therefore allows Ajax to load all the base once and have titles etc and it'll keep reloading the page every time for a new photo.

    Inserting via dhtml that is feasible is right but I want to learn Ajax

Similar Threads

  1. EXCEL Lookup the same value that has multiple values
    By horse43 in forum Windows Software
    Replies: 1
    Last Post: 09-06-2012, 11:42 AM
  2. Lookup multiple values in excel
    By Alatar1313 in forum Windows Software
    Replies: 1
    Last Post: 09-12-2009, 02:49 AM
  3. Replies: 5
    Last Post: 27-10-2009, 12:40 AM
  4. php return multiple values
    By Aston5 in forum Software Development
    Replies: 2
    Last Post: 29-06-2009, 10:14 PM
  5. Excel : vlookup multiple values
    By Laler in forum Windows Software
    Replies: 3
    Last Post: 25-06-2009, 10:27 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,508,129.60457 seconds with 17 queries