MyBB Community Forums

Full Version: Database queries.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
(2017-05-01, 04:13 PM)broatcast Wrote: [ -> ]you need to eval this variable to use it in the template system

Can you give me an example on how to do that?

PS :- I have made a new plugin just like .m. told me to and all this code is in there.
if you have it in a plugin than you can make it global usable
https://docs.mybb.com/1.8/development/pl...a-template
No I had to add the global_start hook and its working now.

However one more question.

So the thing is I did get the records I require and I'm trying to put them all in a nice HTML table however it isn't working as all the records are being fixed in the same row. It isn't able to shift to new rows.

Is there any way in MyBB to change rows to display different data?

I'm using
$housingvar .= "<td>". $result['username']. "</td> \n"; 
$price .= "<td>". $result['Price']. "</td>";
$city .= "<td>". $result['City']. "</td>";
$tax .= "<td>". $result['Tax']. "</td>";
$adrz .= "<td>". $result['Adress']. "</td>";

table code needs to be started before getting the results & it should be closed after getting the results.
i.e. your result should be wrapped with required table code (starting code & ending code).
echo "<table>";

while($result = $db->fetch_array($query))
{
  echo "<tr>";
  echo "<td>" . $result['username'] . "</td>"; 
  echo "</tr>";
}
echo "</table>";

Something like this? However echo is causing the usual problems, I have 2 tables right now on the page.. Do you mind giving me an example?
^ echo should not be used. you have to use code like $housingvar .= ____________ for the table code also.
basically table code should have rows & cells

if you look again at earlier suggested attachment file then you should be able to get it
(table code is not used in that file - it has some different code ..)
(2017-05-02, 01:03 AM).m. Wrote: [ -> ]^ echo should not be used. you have to use code like $housingvar .= ____________ for the table code also.
basically table code should have rows & cells  

if you look again at earlier suggested attachment file then you should be able to get it
(table code is not used in that file - it has some different code ..)
yes I do understand that. I tried with echo. 

while($result = $db->fetch_array($query))
{


$housingvar .= "<td>". $result['username']. "</td>";
$price .= "<td>". $result['Price']. "</td>";


    }

And I called the variables inside a <tr> in the template.


However that didn't help.

Still need help on this. Anyone?

Thread can be closed. Figured it out. Thanks for the help.
Pages: 1 2