Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: Tabpanel autoload php with mysql into a new tab?

  1. #1
    Ext User
    Join Date
    Dec 2010
    Location
    Hungary
    Posts
    24

    Question Tabpanel autoload php with mysql into a new tab?

    Hi!

    I'm new here, and also new to ExtJs.
    I tried to upgrade my webpage with Ext, and I figured, that I make a viewport, a menu at north, info at west, and the main contains at the center. I made everything, but I put a tabpanel at center, and I want that if I click a menu entry at the top, then the selected page load into a new tab at the center. It works well if I use simple html, or pure php without session and without mysql, but I want to use mysql and session also, so I need your help.
    The js code on the main page:
    PHP Code:
    Ext.onReady(function()
            {
                
    Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
                var 
    tabs = new Ext.TabPanel({
                        
    region'center',
                        
    margins'0 5 5 0',
                        
    activeTab0,     
                        
    enableTabScroll:true,
                        
    defaults: {autoScroll:true},
                        
    items: [{
                            
    contentEl'fooldal',
                            
    title'F?oldal',
                            
    closablefalse,
                            
    autoScrolltrue
                        
    }]
                    })
                var 
    viewport = new Ext.Viewport({
                    
    layout'border',
                    
    items: [
                    
    // create instance immediately
                    
    new Ext.BoxComponent({
                        
    region'north',
                        
    height48
                        
    contentEl'menu'
                    
    }), {
                        
    region'west',
                        
    id'west-panel',
                        
    title'',
                        
    splitfalse,
                        
    width205,
                        
    minSize175,
                        
    maxSize400,
                        
    collapsibletrue,
                        
    margins'0 0 5 5',
                        
    contentEl'west'
                    
    },tabs
                   
                    
    ]
                });
                
    /** Add Tab *******************/
                
    function addTab(name,tab_url){
                        
    tabs.add({
                            
    titlename,
                            
    iconCls'tabs',
                
    closable:true,
                            
    autoLoad: {url:tab_urlscriptstrue},
                
    listeners:{
                        
    vate : function(panel){
                        
    panel.getUpdater().refresh();
                         }
                    }
                        }).
    show();
                    }
                
    Ext.get('sajat_beo').on('click',function(){addTab('Sajt beoszts','./pages/info2.php');});
            }); 
    And the info2.php:
    PHP Code:
    <div>
    <?php
    session_start
    ();
                            echo 
    $_SESSION["db"];
                            
    $query="SELECT * FROM mozik";
                            
    $eredm=mysql_query($query,$_SESSION["db"]);
                              while(
    $rekord=mysql_fetch_array($eredm))
                              {
                                echo 
    $rekord["mnev"]."<br/>";
                              }
                            
                            
                      
    ?>
    </div>

  2. #2
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,245

    Default

    Doesn't look incorrect.

    Can you check what info2.php actually returns (check the Firebug Net tab)?

  3. #3
    Ext User
    Join Date
    Dec 2010
    Location
    Hungary
    Posts
    24

    Default

    I checked, and I get this:

    - Answer headers:
    Date Tue, 28 Dec 2010 12:17:41 GMT
    Server Apache/2.2.16 (Ubuntu)
    X-Powered-By PHP/5.3.3-1ubuntu9.1
    Expires Thu, 19 Nov 1981 08:52:00 GMT
    Cache-Control no-store, no-cache, must-revalidate, post-check=0, pre-check=0
    Pragma no-cache
    Vary Accept-Encoding
    Content-Encoding gzip
    Content-Length 30
    Keep-Alive timeout=15, max=81
    Connection Keep-Alive
    Content-Type text/html

    - Request headers:
    Host localhost
    User-Agent Mozilla/5.0 (X11; U; Linux i686; hu-HU; rv:1.9.2.13) Gecko/20101206 Ubuntu/10.10 (maverick) Firefox/3.6.13
    Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    Accept-Language hu-hu,hu;q=0.8,en-us;q=0.5,en;q=0.3
    Accept-Encoding gzip,deflate
    Accept-Charset ISO-8859-2,utf-8;q=0.7,*;q=0.7
    Keep-Alive 115
    Connection keep-alive
    X-Requested-With XMLHttpRequest
    Referer http://localhost/manpower_manager3/main.php
    Cookie ys-west-panel=o%3Acollapsed%3Db%253A0; PHPSESSID=96pg5behfav6e4gni0s6hn80j4

    - Answer:
    <div>
    0</div>

    - HTML:
    0

  4. #4
    Ext User
    Join Date
    Dec 2010
    Location
    Hungary
    Posts
    24

    Default

    The other problem that, when I write the $_SESSION["db"] on the main page I get "Resource id #3", but when I write it on the loaded tab I get "0", so the session doesn't work, and the database connection also doesn't work, and if I trie to connect before the query on info2.php I get "500 Internal Server Error"

  5. #5
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,245

    Default

    And what is wrong with that?

    Your server is returning:
    HTML Code:
    <div>
    0</div>
    so I assume that your "mozik" table only has a single record with "mnev"=0.

  6. #6
    Ext User
    Join Date
    Dec 2010
    Location
    Hungary
    Posts
    24

    Default

    The problem when I put the code of info2.php into a div and use as contentel in a tab, it works (write: Szeged,Veszprm,Debrecen,Alba), but if I autoload it it doesn't work (write nothing).
    The mysql_query has to return 4 result, but it return 0.

  7. #7
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,245

    Default

    This is a PHP problem and I'm not a PHP programmer, so this is not really the correct forum to ask this.

    The '0' in your output is the result from 'echo $_SESSION["db"];', so I assume you don't have a db in your session yet.

  8. #8
    Sencha User mschwartz's Avatar
    Join Date
    Nov 2008
    Location
    San Diego, Peoples' Republic of California
    Posts
    2,061

    Default

    I don't think you can store a mysql DB handle in $_SESSION.

    PHP serializes the object and writes it to a file (in /tmp or some other directory) when the request is complete. session_start() will read the file and unserialize the object. I am quite sure you can't serialize an object that has an open socket like a mysql DB handle.

  9. #9
    Ext User
    Join Date
    Dec 2010
    Location
    Hungary
    Posts
    24

    Default

    The php code is OK, I think because if I put it into a div and make a tab from the div with contetEl like fooldal in the first source code, it works.
    The problem is when I trie to autoload it into the new tab. Somewhy the session, and the mysql_connect doesn't work if I autoload the php file. I tried to load with autoload other php files, what are works good (if I run it in the webbrowser simply or put it into the fooldal div, what is a static tab with contentEl), but they also not work in the autoload tab. First I think it's because of the connection is missing, but when I tried to connect from the autoload file, and not from the main file(what contains the viewport and the tabpanel), I get 500 Internal Server Error. Then I tried to use Session, and that's why I put the db resource into a session variable, but in the autoload page the session also doesn't work

  10. #10
    Sencha User mschwartz's Avatar
    Join Date
    Nov 2008
    Location
    San Diego, Peoples' Republic of California
    Posts
    2,061

    Default

    http://bytes.com/topic/php/answers/1...socket-session

    Your DB handle is roughly equivalent to a socket. The answers in that WWW page are true for DB handles.

    I can see your PHPSESSID cookie is being sent, so the session should be proper otherwise.

Page 1 of 2 12 LastLast

Similar Threads

  1. roweditor with mysql and php
    By evang in forum Ext 3.x: Help & Discussion
    Replies: 3
    Last Post: 24 May 2010, 7:33 AM
  2. ExtJS with PHP and MySQL
    By churcho in forum Ext 3.x: Help & Discussion
    Replies: 8
    Last Post: 13 Aug 2009, 8:23 AM
  3. Example php mysql
    By waxx in forum Ext 2.x: Help & Discussion
    Replies: 11
    Last Post: 9 Jul 2009, 6:26 AM
  4. TabPanel inside Tab (autoLoad)
    By flumueller in forum Ext 2.x: Help & Discussion
    Replies: 8
    Last Post: 1 Nov 2007, 7:43 AM
  5. Ext Tab Panel get Data from PHP connected to MySQL?
    By tomyken in forum Ext 2.x: Help & Discussion
    Replies: 0
    Last Post: 7 Oct 2007, 12:45 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •