Categories > Your tips & tricks >

Simple mysql query

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Las
Date: 2008-10-06
Time: 13:24

Simple mysql query

Hi, I've got a problem with a simple mysql query, to show top 10 news in my sidebar:
in sidebar.php
<?php
include_once('tbs_class.php');

//connection a la base de données
$connection = mysql_connect('localhost', 'root','') or die(mysql_error());
mysql_select_db('mybase', $connection);

$TBS = new clsTinyButStrong;
$TBS->LoadTemplate('../templates/sidebar.tpl');
$TBS->MergeBlock('blk1', $connection, 'SELECT id, title FROM news ORDER BY affichages DESC LIMIT 10');
mysql_close($connection);
$TBS->Show();
?>
and in sidebar.tpl
<a href=articles.php?id=[blk1.id]>[blk1.title]</a><br />

in the page I see one link [blk1.title]

can you help please ?
By: Skrol29
Date: 2008-10-06
Time: 22:51

Re: Simple mysql query

hi Las,

You have to use parameter "block=" (in one of your TBS fields) in order to define the section to be repeated. Otherwise TBS merges only one record.
By: Las
Date: 2008-10-07
Time: 11:57

Re: Simple mysql query

Thanks for the reply, but it's still not working:
I tried all this cases:
<a href=articles.php?id=[blk1.id;block=a]>[blk1.title;block=a]</a><br />
<div><a href=articles.php?id=[blk1.id;block=div]>[blk1.title;block=div]</a></div>
<p><a href=articles.php?id=[blk1.id;block=p]>[blk1.title;block=p]</a></p><br />
By: Skrol29
Date: 2008-10-07
Time: 22:13

Re: Simple mysql query

All of those should work.
You can put only one "block=", they are not needed on each fields.

What is not working. What result do you have exactly ?
By: Las
Date: 2008-10-08
Time: 13:46

Re: Simple mysql query

this is how it looks like after putting "block=" in all the cases:
http://d.imagehost.org/view/0062/tbs.png
By: Skrol29
Date: 2008-10-08
Time: 23:19

Re: Simple mysql query

Hi Las,

Thanks for the snapshot. Block "blk1" is not merged at all, there is an unexpected problem somewhere.
Check in top of the source of the result page in order to found any TBS error message. It can be hidden in normal view by some CSS makup.

If there is no error message, just check the content of $TBS->Source before to do the MergeBlock() in order to see if block "blk1" is rigth here.

Regards,
By: BruceB
Date: 2009-03-03
Time: 21:31

Re: Simple mysql query

You should only have the ;block=div once.

<div><a href=articles.php?id=[blk1.id;block=div]>[blk1.title]</a></div>