Members: 16,996
Threads: 38,866
Posts: 159,475
Online: 50

Newest Member: Kl_broka@rediffmail.com


Odoo.tv - Outdoor Television


Sedo - Domains kaufen und verkaufen das Projekt mambers.com steht zum Verkauf Besucherstatistiken von mambers.com etracker® Web-Controlling statt Logfile-Analyse
Old 22.07.2005, 18:34   #1 (permalink)
Baby Mamber
 
Join Date: Apr 2005
Posts: 6
Chunter is on a distinguished road
Default General PHP question

I'm writing a component that adds jobs to a database from a search API that I've paid to be part of. I have most of the component done actually.

http://www.kmbassoc.com/

Then click on job search.

Anyways. I have a members only link that adds jobs to a table which has all the info about the job that the search returns. That part is working.

Now this might be a noob question, but does anyone have a link to some code that simply returns the $rows that are in the table that correspond to their user_id which is also stored in the database. Like I said its probably a simple function, I'm just not all that skilled with MySQL and PHP yet.

Thanks!

Chris
Chunter is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
Old 25.07.2005, 16:01   #2 (permalink)
Baby Mamber
 
Join Date: Jun 2005
Posts: 6
stewie is on a distinguished road
Default Re: General PHP question

This is partly a PHP question, partly a MySQL question and partly a mambo question.

First, in your function, you need to
global $my, $database;

This will allow you to access the $my object. The user's id is accessed through:
$my->id

Then you need to set up a query.

$query = "SELECT * FROM #__table"
. "\n WHERE user_id='".$my->id."'"
;

$database->setQuery( $query );
$rows = $database->loadObjectList();

That should do it. Let me know if you have any questions.

Ian
stewie is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 25.07.2005, 17:55   #3 (permalink)
Baby Mamber
 
Join Date: Apr 2005
Posts: 6
Chunter is on a distinguished road
Default Re: General PHP question

Thanks stewie! I was on the right track but I forgot my global variable declarations. For some reason I thought they were passed automatically.

Also, I'm assuming to print the rows I'll need some sort of foreach loops and check the keys.

Is there a URL you know of that I can use to find the syntax of how to check the key (user_id) and when there are no more keys. I know that at I can do a $keycount++; statement in there, and an echo "<tr><td>". $rows->user_id ; or something like this to print the rows, but the logic to cycle through the each row in the array is a little bit of a mystery to me still. I'm sorry if this is a very basic question. But I still need help!!

I really thank you for taking the time so far.

Chris Hunter.
Chunter is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 27.07.2005, 16:21   #4 (permalink)
Baby Mamber
 
Join Date: Apr 2005
Posts: 6
Chunter is on a distinguished road
Default Re: General PHP question

I figured it out.

I did something like this, this is obviously not the end all, I'm still writing, but this works for now.

if ($task == 'showJob') {

$query = "SELECT user_id, job_id, job_title, job_desc, job_url, job_st, job_company, job_city FROM #__jobsearch_job_id"
. "\n WHERE user_id='".$my->id."'";

$database->setQuery( $query );
$rows = $database->loadObjectList();
if ($rows[0]) {
echo "<table>";
echo "\n<tr>";
echo "\n<td width=\"5%\">" . "Job ID" . "</td>";
echo "\n<td width=\"20%\">" . "Job Title" . "</td>";
echo "\n<td width=\"50%\">" . "Job Description" . "</td>";
echo "\n<td width=\"15%\">" . "Job City" . " " . $row->job_st . "</td>";
echo "\n<td width=\"10%\">" . "Job Link" . "</td>";
echo "</tr>\n";

//echo highlight_string(print_r($rows,true),true);
foreach ($rows as $row) {
$COLORCOUNT++;

if ($COLORCOUNT % 2 == 0 ) {
$CELLCOLOR = "p1";
} else {
$CELLCOLOR = "p2";
}
echo "\n<tr>";
echo "\n<td class=\"" . $CELLCOLOR . "NiftyBody\">" . $row->job_id . "</td>";
echo "\n<td class=\"" . $CELLCOLOR . "NiftyBody\">" . $row->job_title . "</td>";
echo "\n<td class=\"" . $CELLCOLOR . "NiftyBody\">" . $row->job_desc . "</td>";
echo "\n<td class=\"" . $CELLCOLOR . "NiftyBody\">" . $row->job_city . " " . $row->job_st . "</td>";
echo "\n<td class=\"" . $CELLCOLOR . "NiftyBody\">" . "<a href=\"". $row->job_url . "\">View Job</a></td>";
echo "</tr>\n";

}

echo "</table>\n";
}else {
echo "You Have No Jobs In Your List.<br> You can use our search and click the <b>Add to My Jobs</b> Link on each search result.";
}
echo $database->getErrorMsg();
}

If anyone sees anything that I should change lemme know.

Chris
Chunter is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Php Shop Question nocturnal Mambo 4.5.1 'How Do I' Questions 4 22.04.2005 15:27
phpShop General Question Moolkye Component 'How Do I' Questions 2 08.11.2004 17:53
ALL-INKL änder PHP Einstellungen -peter- Smalltalk 2 16.09.2004 17:53
PHP Shop question MissieK Mambo 4.5 'How Do I' Questions 3 18.06.2004 15:00
General Component Programming Question tonyskyday Development Discussions 18 22.04.2004 17:40


All times are GMT +2. The time now is 14:44.

Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.1.0
A vBSkinworks Design
© Copyright 2004-2008 by Arthur Konze Webdesign.