PDA

View Full Version : Help with php



kamakrane
8 Oct 2009, 10:14 AM
hello
i try to get information from the db to update my combo but i dont know what hapend

Index.php

Ext.onReady(function()
{
var genres = new Ext.data.Store({
reader: new Ext.data.JsonReader({
fields: ['id_genre', 'libelle_genre'],
root: 'rows'
}),
proxy: new Ext.data.HttpProxy({
url: 'data.php'
}),
autoLoad: true
});
Ext.QuickTips.init();
var movie_form = new Ext.FormPanel({
url: 'valide.php',
renderTo: document.body,
frame: true,
title: 'Movie Information Form',
width: 250,
items: [{
xtype: 'textfield',
fieldLabel: 'Title',
name: 'title',
allowBlank: false
},{
xtype: 'textfield',
fieldLabel: 'Director',
name: 'director',
vtype: 'alpha'
},{
xtype: 'datefield',
fieldLabel: 'Released',
name: 'released',
disabledDays: [1,2,3,4,5]
},{
xtype: 'radio',
fieldLabel: 'Filmed In',
name: 'filmed_in',
boxLabel: 'Color'
},{
xtype: 'radio',
hideLabel: false,
labelSeparator: '',
name: 'filmed_in',
boxLabel: 'Black & White'
},{
xtype: 'checkbox',
fieldLabel: 'Bad Movie',
name: 'bad_movie'
},{
xtype: 'combo',
name: 'genre',
fieldLabel: 'Genre',
mode: 'local',
store: genres,
displayField:'genre',
width: 120
},{
xtype: 'htmleditor',
name: 'description',
hideLabel: true,
labelSeparator: '',
height: 100,
anchor: '100%'
}]
});
}) ;

data.php

<?php
include("config.php");
$result = mysql_query('SELECT id_genre, libelle_genre FROM genre');
If (mysql_num_rows($result) > 0)
{
while ($obj = mysql_fetch_object($result))
{
$arr[] = $obj;
}
}
Echo '{rows:'.json_encode($arr).'}';
?>

please some one can help me

httpdotcom
8 Oct 2009, 11:52 AM
use [ code ] ... [ /code ] tags in your post.

1) instead of mysql_fetch_object, try mysql_fetch_assoc() if it isn't producing the expected results (check firebug for result)

2) in your echo statement, try

echo json_encode( array( "rows" => $arr ) ) ;

3) in your combo, your display field doesn't match any field in your store, and you have no valueField config

kamakrane
8 Oct 2009, 12:25 PM
hello

where should I use [ code ] ... [ /code ] ,
and how can i instance the valueField

thanks a lot
because i'm new

Jack9
8 Oct 2009, 2:37 PM
&#91;CODE&#93;
//THIS IS A CODE BLOCK
// Dont just paste code. Put it in these.
&#91;/CODE&#93;

adibhagra
9 Oct 2009, 9:32 AM
i don't understand why you have given the displayField as 'genre' when in your stores your fields are named something else(id_genre and libelle_genre).try changing that and see if it works :)

all the best

Ice

kamakrane
9 Oct 2009, 5:36 PM
thanks a lot guys it works
know im going to try grid some one can coach me thanks