Printable Version of Topic

Click here to view this topic in its original format

HTMLHelp Forums _ Databases _ SQL query in pyramid structure

Posted by: Barbara Dec 17 2015, 04:59 PM

Hi! I have problem with displaying sql query in pyramid structure (it is made like a table). I am working in Wordpress. I want to display name by his pyramid number and I want to show it in table (pyramid). I don't know what loop is best for that. I have made something like this: get_results("SELECT pyramid_number, CONCAT(name,' ',last_name) AS user_name FROM users");?>

And this is the first row of my pyramid. I have tried to put pyramid number inside <td> and user_name between <td></td> but obviously I don't know how.

<table class="pyramid">
<tbody>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td if pyramid_number=1>user_name</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>

Posted by: CharlesEF Dec 17 2015, 07:07 PM

I know nothing about Wordpress but if you are using PHP for this then you need to post your code.

Posted by: Barbara Dec 18 2015, 02:29 AM

QUOTE(CharlesEF @ Dec 18 2015, 01:07 AM) *

I know nothing about Wordpress but if you are using PHP for this then you need to post your code.


I don't understand. blush.gif

Posted by: CharlesEF Dec 18 2015, 04:26 AM

QUOTE(Barbara @ Dec 18 2015, 01:29 AM) *

QUOTE(CharlesEF @ Dec 18 2015, 01:07 AM) *

I know nothing about Wordpress but if you are using PHP for this then you need to post your code.


I don't understand. blush.gif

You've already shown this part of code:
CODE
get_results("SELECT pyramid_number, CONCAT(name,' ',last_name) AS user_name FROM users");?>
That line is part of PHP code because of the PHP closing tag '?>'. 'get_results(...)' is a Wordpress function, most likely written in PHP, that will query the database and return the data, in this case 'pyramid_number' and 'user_name'. The function call needs a variable to hold the data so the actual code would be something like this: '$somevaraible = get_results(...);'. At this point you would need PHP code to build the table and insert the data. The table can't be hard coded because you won't know how much data is returned.

I can help you write the PHP code but I can't write it for you. But, in order to help I would need to see the PHP code you are working on (or attach the page to a post). How much programming experience do you have?

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)