The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> SQL query in pyramid structure
Barbara
post Dec 17 2015, 04:59 PM
Post #1





Group: Members
Posts: 2
Joined: 17-December 15
Member No.: 23,837



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>
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
CharlesEF
post Dec 17 2015, 07:07 PM
Post #2


This is My Life
*******

Group: Members
Posts: 1,437
Joined: 27-April 13
From: Edinburg, Texas
Member No.: 19,088



I know nothing about Wordpress but if you are using PHP for this then you need to post your code.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Barbara
post Dec 18 2015, 02:29 AM
Post #3





Group: Members
Posts: 2
Joined: 17-December 15
Member No.: 23,837



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
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
CharlesEF
post Dec 18 2015, 04:26 AM
Post #4


This is My Life
*******

Group: Members
Posts: 1,437
Joined: 27-April 13
From: Edinburg, Texas
Member No.: 19,088



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?

This post has been edited by CharlesEF: Dec 18 2015, 04:32 AM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 18th December 2017 - 03:13 PM