How to pull info from database (help Please)

Ben144

Member
Jan 31, 2017
76
5
Hey i am recreating the jobs page on the FluxRP CMS and am trying to pull the relevant data from the rp_jobs table, but i am having no luck as when i want to display the owners name, then i put owner_id, but it only displays the owners id and not their full username. The same goes for the avatar it isn't pulling the owner's avatar look ect.

You must be registered for see images attach


Code:
<div class="corporation-index-grid">
                    <div class="corp">
                <div class="content-box">
                <?php
                $badgepath = "{url}/fluxweb/corps/";
                
                $q = mysql_query("SELECT * FROM rp_jobs WHERE type = 'skilled' AND hidden = 0 ");
                    while($row = mysql_fetch_assoc($q))
                {
            
                echo "<div class='title'>" . $row['name'] . " <span class='title-small float-right'><small>20 employees</small></span></div>
                      <div class='box-content d-flex justify-content-center align-items-center p-0'>
                        <div class='' style='margin-left: -15px;'>
                            <div class='manager-wrapper'>
                                <img src='https://www.habbo.nl/habbo-imaging/avatarimage?figure=".$owner['look']."&amp;direction=2&amp;gesture=sml&amp;size=l'>
                            </div>
                        </div>
                        <div class='mr-auto'>Managed by <strong>".$owner['username']."</strong></div>
                        <div class='pr-3'>
                            <img class='corporation-badge' src='" . $badgepath . $row['badge'] . ".gif'>
                        </div>
                        <div class='pr-3 d-flex'>
                            <div class='mr-1'><a class='button blue pr-1' href=" . JobsView() . $row['id'] . "'>View <i class='far fa-arrow-alt-circle-right'></i></a></div>
                            <div class='ml-1'> <a class='button discord' href=''><i class='fab fa-discord'></i></a></div>
                        </div>
                        </div>";
        }
        
    
    ?>
    </div>
    </div>
    </div>
    </div>

Any help appreciated and thanks in advance
 

Ben144

Member
Jan 31, 2017
76
5
I’m not sure why you ripped PeakRP’s style. Where is the CMS based on? Laravel or RevCMS?
I don’t know what the cms are actually called, but they are so outdated and you think I have ripped a cms of another website/game. Did it ever occur to you that I am maybe good at HTML and CSS. You also have not answered the question that was asked.
 

Michell

god x
Nov 15, 2011
167
24
I don’t know what the cms are actually called, but they are so outdated and you think I have ripped a cms of another website/game. Did it ever occur to you that I am maybe good at HTML and CSS. You also have not answered the question that was asked.
I ask this, because it can be different on each CMS how to pull info from the database. Good at HTML and CSS or not, it's still PeakRP's style. Could you send a screenshot of the wwwroot / htdocs folder? That way I should be recognize the CMS base.
 

Ben144

Member
Jan 31, 2017
76
5
I ask this, because it can be different on each CMS how to pull info from the database. Good at HTML and CSS or not, it's still PeakRP's style. Could you send a screenshot of the wwwroot / htdocs folder? That way I should be recognize the CMS base.
You must be registered for see images attach

Post automatically merged:

I am using FluxRP CMS & Emulator ect
 

doe

New Member
Jan 29, 2021
23
7
Could you send a screenshot of the wwwroot / htdocs folder? That way I should be recognize the CMS base.
Uhm, I don't exactly understand you. Why should it be CMS relevant when he provides the Query with the loop? Maybe I'm misunderstanding something here...

It looks to me, that you're using the wrong variable name for your output. you assuming the output of fetch_assoc to $row and not to $owner. So you have to change $owner['username'] into $row['username'], same with the avatar.
 

Ben144

Member
Jan 31, 2017
76
5
Uhm, I don't exactly understand you. Why should it be CMS relevant when he provides the Query with the loop? Maybe I'm misunderstanding something here...

It looks to me, that you're using the wrong variable name for your output. you assuming the output of fetch_assoc to $row and not to $owner. So you have to change $owner['username'] into $row['username'], same with the avatar.
Their is not change :/
 

Ben144

Member
Jan 31, 2017
76
5
My bad... Could you please upload your rp_jobs table and for being safe your users table?
Sure give me a sec
Post automatically merged:

My bad... Could you please upload your rp_jobs table and for being safe your users table?
My rp_jobs table is:

You must be registered for see images attach


Users table is:

You must be registered for see images attach
 
Last edited:

doe

New Member
Jan 29, 2021
23
7
I see... The problem is: You only get the values from your rp_jobs table without a connection to your users table. You need to build a relation with the users table. Try this query instead:

SQL:
$q = mysql_query("SELECT * FROM rp_jobs AS rp LEFT JOIN users AS u ON rp.userid = u.id WHERE rp.type = 'Skilled' and rp.hidden = 0");

I'm not sure where the "hidden" columns is from. If you encounter errors try to the change the text "rp.hidden = 0" to "u.hidden = 0". If you still encounter problems delete "rp.hidden = 0" from your query.
 

Ben144

Member
Jan 31, 2017
76
5
I see... The problem is: You only get the values from your rp_jobs table without a connection to your users table. You need to build a relation with the users table. Try this query instead:

SQL:
$q = mysql_query("SELECT * FROM rp_jobs AS rp LEFT JOIN users AS u ON rp.userid = u.id WHERE rp.type = 'Skilled' and rp.hidden = 0");

I'm not sure where the "hidden" columns is from. If you encounter errors try to the change the text "rp.hidden = 0" to "u.hidden = 0". If you still encounter problems delete "rp.hidden = 0" from your query.
Now the below has removed from the page:

You must be registered for see images attach


Code:
<div class="content">

        <div class="container">
            
    <div class="corporation-index-grid">
                    <div class="corp">
                <div class="content-box">
                <?php
                $badgepath = "{url}/fluxweb/corps/";
                
                
                $q = mysql_query("SELECT * FROM rp_jobs AS rp LEFT JOIN users AS u ON rp.userid = u.id WHERE rp.type = 'Skilled' and rp.hidden = 0");
                    while($row = mysql_fetch_assoc($q))
                {
            
                echo "<div class='title'>" . $row['name'] . " <span class='title-small float-right'><small>20 employees</small></span></div>
                      <div class='box-content d-flex justify-content-center align-items-center p-0'>
                        <div class='' style='margin-left: -15px;'>
                            <div class='manager-wrapper'>
                                <img src='https://www.habbo.nl/habbo-imaging/avatarimage?figure=".$row['look']."&amp;direction=2&amp;gesture=sml&amp;size=l'>
                            </div>
                        </div>
                        <div class='mr-auto'>Managed by <strong>" . $row['username'] . "</strong></div>
                        <div class='pr-3'>
                            <img class='corporation-badge' src='" . $badgepath . $row['badge'] . ".gif'>
                        </div>
                        <div class='pr-3 d-flex'>
                            <div class='mr-1'><a class='button blue pr-1' href=" . JobsView() . $row['id'] . "'>View <i class='far fa-arrow-alt-circle-right'></i></a></div>
                            <div class='ml-1'> <a class='button discord' href=''><i class='fab fa-discord'></i></a></div>
                        </div>
                        </div>";
                }
                ?>
    </div>
    </div>
    </div>
    </div>
 

Users who are viewing this thread

Top