Page 1 of 1

Problem with user profiles

Posted: Fri Jul 20, 2012 2:35 pm
by Ramariodepass
Hi, I'm creating this job site. I have created some dummy user profiles and I want these profiles to only show jobs posted by that company for example.

A company called Janko logs into this website. They are then ask to create a job.
So they create a job called "Marketing Intern". All of their jobs can be found at http://pleekant.com/Janko

However, the method I am currently using to fetch the jobs from the database is fetching all of the jobs, including jobs from other companies. For example, at http://pleekant.com/Janko, there are jobs from other companies on that page and vice versa.

I want to make it so, only jobs posted by Janko are found at http://pleekant.com/Janko and not every single job in the jobs table.

This is the current code I am using to return jobs
    <?
                                            
    $q = mysql_query("SELECT `users`.`user_id`, `users`.`company_name`, `jobs`.`user_id`,
    `jobs`.`job_title`, `jobs`.`job_id`
    FROM `users` INNER JOIN `jobs` ON `users`.`user_id` = `jobs`.`user_id`
    WHERE `jobs`.`user_id` = `users`.`user_id`
    ORDER BY `jobs`.`user_id` DESC LIMIT 20");
    $jobs = array();
    while($r = mysql_fetch_assoc($q)){
        $jobs[] = array(
        'user_id' => $r['user_id'],
        'company_name' => $r['company_name'],
        'job_title' => $r['job_title'],
        'job_id' => $r['job_id']
    );
        
    }
    foreach($jobs as $j) {
    $job_title = $j['job_title'];
    $company_name = $j['company_name'];
    $job_id = $j['job_id'];
    ?>
                                <li class="one-third video">
                                <div class="portfolio-item-holder">
                                
                                </div>
    <h4><a href="<?php echo $company_name?>.php?job_id=<?php echo $job_id ?>"><?php echo $job_title?></a></h4>
                                
                                </li>
    <?php
    }
    ?>



Thu Jul 19, 2012 12:39 pm
Hi, I'm creating this job site. I have created some dummy user profiles and I want these profiles to only show jobs posted by that company for example.

A company called Janko logs into this website. They are then ask to create a job.
So they create a job called "Marketing Intern". All of their jobs can be found at http://pleekant.com/Janko

However, the method I am currently using to fetch the jobs from the database is fetching all of the jobs, including jobs from other companies. For example, at http://pleekant.com/Janko, there are jobs from other companies on that page and vice versa.

I want to make it so, only jobs posted by Janko are found at http://pleekant.com/Janko and not every single job in the jobs table.

This is the current code I am using to return jobs

textpop-up
   <?
                                            
    $q = mysql_query("SELECT `users`.`user_id`, `users`.`company_name`, `jobs`.`user_id`,
    `jobs`.`job_title`, `jobs`.`job_id`
    FROM `users` INNER JOIN `jobs` ON `users`.`user_id` = `jobs`.`user_id`
    WHERE `jobs`.`user_id` = `users`.`user_id`
    ORDER BY `jobs`.`user_id` DESC LIMIT 20");
    $jobs = array();
    while($r = mysql_fetch_assoc($q)){
        $jobs[] = array(
        'user_id' => $r['user_id'],
        'company_name' => $r['company_name'],
        'job_title' => $r['job_title'],
        'job_id' => $r['job_id']
    );
        
    }
    foreach($jobs as $j) {
    $job_title = $j['job_title'];
    $company_name = $j['company_name'];
    $job_id = $j['job_id'];
    ?>
                                <li class="one-third video">
                                <div class="portfolio-item-holder">
                                
                                </div>
    <h4><a href="<?php echo $company_name?>.php?job_id=<?php echo $job_id ?>"><?php echo $job_title?></a></h4>
                                
                                </li>
    <?php
    }
    ?>


I need some kind of statement that only shows jobs that match the company's id, in the jobs table.
P.s the user_id is the company id

Re: Problem with user profiles

Posted: Fri Jul 20, 2012 3:00 pm
by Ramariodepass
SOLVED