Reply
Pulling multiple details from MySQL
Old 01-30-2008, 01:11 PM Pulling multiple details from MySQL
Experienced Talker

Posts: 34
Name: Jin
Location: Bangkok
Trades: 0
I am trying to pull information from a database table and display it on a web page the page will display

1. Project Name
2. Status
3. Other

I am using the query below to get the information and number 2 and 3 are working fine but I can't get number 1 to work. I tried multiple different ways and all have failed. The name of the field I am trying to pull is "id" listed in the same table freelancers_bids. The information held for the id will only be displayed if there is a project opened or frozen in which you can see the query below and that is working fine.

How can I amend this so the information in the id field gets displayed also?

Code:
 
$tinyres = SQLact("query", "SELECT * FROM freelancers_bids WHERE username='" . $username . "' AND status='open' OR username='" . $username . "' AND status='frozen' ORDER BY date DESC");
Thai Freelance is offline
Reply With Quote
View Public Profile Visit Thai Freelance's homepage!
 
 
When You Register, These Ads Go Away!
Old 01-30-2008, 03:18 PM Re: Pulling multiple details from MySQL
Skilled Talker

Posts: 94
Trades: 0
You are using * So everything in that table is being pulled. Doesn't appear to be a problem with your MySQL statement.
__________________
Sell Templates? Try our Template Monster WebAPI! See a live Template Shop Demo
ChadR is offline
Reply With Quote
View Public Profile
 
Old 01-30-2008, 03:41 PM Re: Pulling multiple details from MySQL
Experienced Talker

Posts: 34
Name: Jin
Location: Bangkok
Trades: 0
What I have shown all works fine but when I try to grab the id from the table it isn't working I am not sure what to use to grab the info, as an example I am wondering how to add something like this:

Code:
 
FROM freelancers_bids WHERE id='" . $id . "' username='" . $username . "'
But I am not sure how to include the id in there as well because it should only show information when there is an "open" or a "frozen"
Thai Freelance is offline
Reply With Quote
View Public Profile Visit Thai Freelance's homepage!
 
Old 01-30-2008, 03:54 PM Re: Pulling multiple details from MySQL
joder's Avatar
Flipotron

Posts: 6,441
Name: James
Location: In the ocean.
Trades: 0
The problem isn't with the SQL but with the scripting that is displaying the information.
joder is offline
Reply With Quote
View Public Profile
 
Old 01-31-2008, 03:13 AM Re: Pulling multiple details from MySQL
Average Talker

Posts: 17
Trades: 0
One thing you might try is having your application output the query (not the result.) Copy and paste it into your SQL monitor/enterprise manager/whatever you use and see what it returns. Then you will have a better idea of what you are doing. Any time I write an SQL query in code and I don't understand the results I'm getting, I always have my program tell me the actual query, and then I paste it into MySQL. After I have it tweaked to extract the data properly, then I put it back into my code.

By the way, don't use select * unless you need EVERY column returned.
Crankshaft is offline
Reply With Quote
View Public Profile
 
Old 01-31-2008, 11:40 AM Re: Pulling multiple details from MySQL
Experienced Talker

Posts: 34
Name: Jin
Location: Bangkok
Trades: 0
I know I am missing something simple if anyone can spot it please let me know.

Here is the complete code that I am using trying to get the out put.

PHP Code:
<table width="100%" border="' . $tableborder . '" cellspacing="' . $tablecellsp . '" cellpadding="' . $tablecellpa . '">
<
tr>
<
td bgcolor="' . $tablecolorh . '"><small><b><font color=' . $tablecolort . '>Project Name</td>
<
td bgcolor="' . $tablecolorh . '"><small><b><font color=' . $tablecolort . '>Status</td>
<
td bgcolor="' . $tablecolorh . '"><small><b><font color=' . $tablecolort . '>Other</td>
</
tr>';
$tinyres = SQLact("query", "SELECT * FROM freelancers_bids WHERE username='" . $username . "' AND status='
open' OR username='" . $username . "' AND status='frozen' ORDER BY id ASC");
$tinyrows = SQLact("num_rows", $tinyres);
if ($tinyrows==0) {
echo '
<tr><td bgcolor=' . $tablecolor1 . ' colspan=4><center><small>(Only open frozen projects are displayed here.)</td></tr>';
} else {
while ($kikrow=SQLact("fetch_array", $tinyres)) {
echo '
<tr> <td bgcolor="' . $tablecolor1 . '"><small><a href="' . $siteurl . '/project.php?id=' . $kikrow[id] . '">' . $kikrow[project] . '</a>';
if ($kikrow[special] == "featured") {
echo ' 
<a href="' . $siteurl . '/featured.php"><img src="' . $siteurl . '/images/featured.gif" alt="Thai Freelancers Featured Project." border=0>';
}
echo '
</td> <td bgcolor="' . $tablecolor1 . '"><small>';
if ($kikrow[status] == "open") {
echo '
<font color=green><b>' .  $kikrow[status];
} else {
echo '
<font color=black><b>' .  $kikrow[status];
}
echo '
</td> <td bgcolor="' . $tablecolor1 . '"><small>';
if ($kikrow[chosen] == $username) {
echo '
Bid Won: <a href="' . $siteurl . '/freelancers.php?manage=2&confirm2=' . $kikrow[id] . '">Accept/Deny Offer</a>';
} else {
echo '
<a href="' . $siteurl . '/freelancers.php?manage=2&retract=' . $kikrow[id] . '">Retract Your Bid</a>';
}
echo '
</td></tr>;
}

Thai Freelance is offline
Reply With Quote
View Public Profile Visit Thai Freelance's homepage!
 
Old 01-31-2008, 11:46 AM Re: Pulling multiple details from MySQL
Experienced Talker

Posts: 34
Name: Jin
Location: Bangkok
Trades: 0
I found it I new it was something simple.

It is calling to an empty table with this:

PHP Code:
echo '<tr> <td bgcolor="' $tablecolor1 '"><small><a href="' $siteurl '/project.php?id=' $kikrow[id] . '">' $kikrow[project] . '</a>'
Once I changed it to this:

PHP Code:
echo '<tr> <td bgcolor="' $tablecolor1 '"><small><a href="' $siteurl '/project.php?id=' $kikrow[id] . '">' $kikrow[id] . '</a>'
The info was out put but for some reason the table for projects is empty when it shouldn't be so now on to look for the problem there.
Thai Freelance is offline
Reply With Quote
View Public Profile Visit Thai Freelance's homepage!
 
Old 01-31-2008, 12:02 PM Re: Pulling multiple details from MySQL
joder's Avatar
Flipotron

Posts: 6,441
Name: James
Location: In the ocean.
Trades: 0
Good work solving that problem. Let's us know if we can help further.
joder is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Pulling multiple details from MySQL
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.12340 seconds with 13 queries