Page 1 of 1
Help a noob out with some basics
Posted: Tue Feb 09, 2010 9:46 pm
by Whirlpoolz
Hi, I need help displaying information from my database. I'm using a php file and then an html file for the template itself. My php looks something like this:
Code: Select all
$result = $db->query("SELECT * FROM `my_table_here` ORDER BY `field_i_want_to_sort_by` DESC LIMIT 0,10");
{
$tmp->set_block( 'my_list', $row );
}
I want to display the information in html like this:
Code: Select all
<!-- start my_list -->
{my_list.field_1}, {my_list.field_2}<br />
<!-- stop my_list -->
So basically, I want to display the different fields of that table. What changes do I need to make to make this work? If you can explain any of the "how"'s or "why"'s of it, that would be cool too. Thanks.
Re: Help a noob out with some basics
Posted: Wed Feb 10, 2010 1:44 am
by klevis miho
Why is this:
$tmp->set_block( 'my_list', $row );
inside curly brackets?
Re: Help a noob out with some basics
Posted: Wed Feb 10, 2010 4:01 am
by Whirlpoolz
All of the examples I've seen, they always show that part in the brackets, so I assumed they were supposed to go in there.
Re: Help a noob out with some basics
Posted: Wed Feb 10, 2010 4:09 am
by social_experiment
Unless $tmp->set_block( 'my_list', $row ) is a function that creates the list somehow, you could use mysql_fetch_array() to display the desired fields :
Code: Select all
<?php $result = $db->query("SELECT * FROM `my_table_here` ORDER BY `field_i_want_to_sort_by` DESC LIMIT 0,10");
while ($value = mysql_fetch_array($result)) {
echo "$value[field1]";
echo "$value[field2]";
//etc
}?>
Re: Help a noob out with some basics
Posted: Wed Feb 10, 2010 4:17 am
by Whirlpoolz
I tried that and got the same result.
Is the html I posted correct with what I'm trying to do with the php? I know I used that form of displaying the information in the past and got it to work, but I feel very helpless right now.
Re: Help a noob out with some basics
Posted: Wed Feb 10, 2010 5:57 am
by social_experiment
The html in this example is irrelevant. Could you please post the complete script or attach it as a file, that would be more helpful. What output (if any) do you receive?