Login   Register  
PHP Classes
elePHPant
Icontem

problem with query

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us

      Template Class  >  All threads  >  problem with query  >  (Un) Subscribe thread alerts  
Subject:problem with query
Summary:problem with query
Messages:1
Author:emiliano
Date:2008-04-28 13:38:42
 

  1. problem with query   Reply   Report abuse  
Picture of emiliano
emiliano
2008-04-28 13:38:44
Hi,
my name is Emiliano.
im a student of computer sciences in Rome, Italy.


Now, i have a problem.I dont aunderstand how use the function parse_sql in class template.inc.php.

Can you give me a complete example?
there is an example in zip file.....but dont go.........maybe is me surely.

The declaration in example is:

$pg = pg_connect('user=richard dbname=scripts port=5432');
$sqlquery = 'SELECT col1 AS column_1, col2 AS column_2, col3 AS column_3 FROM test';
$table_rows = pg_exec($pg, $sqlquery);

I use myslq dbms then:

$db=mysql_connect("localhost","root","");
mysql_select_db("dispense2");
$query="SELECT id AS id, nome AS nome FROM corsolaurea ORDER BY id ASC";
$array=mysql_query($query);

NOW:

i call the method in class : class.template.inc.php(i have renamed for not visibility in browser .The original name was: class.template.inc);

$template = new template();
.........
........
$template->load_file("header"
,TEMPLATE_FOLDER."header.html");/*TEMPLATE_FOLDER IS A COSTANT DEFINED IN FILE config.inc.php, set : http://localhost/template_engine/template/
WHERE ARE THE templates in html code .
*/
$template->load_file("content",TEMPLATE_FOLDER."content.html");
.......
$db=mysql_connect("localhost","root","");
mysql_select_db("dispense2");

$query="SELECT id AS id, nome AS nome FROM corsolaurea ORDER BY id ASC";
$array=mysql_query($query);

$template->parse_sql("content",$array );

$template->print_file('header, content,menu');

If i do in this mode, return me a warning:

Warning: mysql_num_fields(): supplied argument is not a valid MySQL result resource in C:\wamp\www\new_template_engine_test\class.template.inc.php on line 157

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\wamp\www\new_template_engine_test\class.template.inc.php on line 158


i have see and there is a variable : $$result_name. I know that this signature is for dinamic variables.
if i delete $$result and write $result_name only, that work (warnings disappears) but dont take the values and i dont see a loop in html template, as method "parse_loop".

At this point, i dont say wath to do.
Can you help me?
Is possible , can you give me a complete example for take recods in msql database and print them whit loop in html template pleeeeeease?

PS:: this is the link of class that i have downloaded:

http://www.phpclasses.org/browse/package/54.html

Thank you so mutch
Sorry for my english :(


have nice day
emiliano