close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Conditions help....

Thread began 2/07/2012 12:45 pm by arturo.civit | Last modified 2/23/2012 12:17 pm by Jason Byrnes | 1550 views | 8 replies |

arturo.civit

Conditions help....

Hi there!

One question, how can I filter something coming from a database in PHP using a conditional, for example, I have a table with posted jobs, those jobs belongs to departments, for example

Brokerage - System
Brokerage - Management
Brokerage - Services
Brokerages - Payroll
Carrier - Real Estate
Carrier - Documents
Carrier - Programming
etc.

If you see, the departments are just 2 Brokerage and Carrier but in the database they are called like I described you Brokerage - Something and Carrier - Something.

I want to have 2 HTML tables, the table in the left with only posting the Brokerage Positions and the one in the right with the Carrier Positions, I used this on the left one:

<?php
if (@$row_rsBJ['Job_Department'] != "Brokerage") {
?>

<?php do { ?>
<table>
</table>
<?php } while ($row_rsBJ = mysql_fetch_assoc($rsBJ)); ?>
<?php }


but didn't work, I need to filter with something like "Send me only departments that start with brokerage" or something like that, but my programming expertise is minimal, any idea? or suggestion?

Thanks so much in advance!

Arturo

Sign in to reply to this post

Jason ByrnesWebAssist

assuming the name of the table is "jobs" and the name of the column is "departments"


you could use the following SQL for Brokerage:
SELECT * FROM jobs WHERE departments LIKE 'Brokerage%'

and this for Carrier:
SELECT * FROM jobs WHERE departments LIKE 'Carrier%'

Sign in to reply to this post

arturo.civit

Originally Said By: Jason Byrnes
  assuming the name of the table is "jobs" and the name of the column is "departments"


you could use the following SQL for Brokerage:
SELECT * FROM jobs WHERE departments LIKE 'Brokerage%'

and this for Carrier:
SELECT * FROM jobs WHERE departments LIKE 'Carrier%'  



Hi Jason, thanks so much!! you're right, that should do the trick, the thing is, my query is a little bit complex, for example, the one that should call the brokerage ones is:


SELECT CompanyInfo.CompanyInfo_Logo, CompanyInfo.CompanyInfo_COName, Jobs.Job_Date, Jobs.Job_Position, Jobs.Job_Salary, Jobs.Job_Department, Jobs.Job_Division, Jobs.Job_City, Jobs.Job_State, Jobs.Job_Contact, Jobs.Job_Email, Jobs.Job_Summary
FROM (Jobs
LEFT JOIN CompanyInfo ON CompanyInfo.ID_User=Jobs.ID_User)
ORDER BY Jobs.Job_Date DESC

So now not sure where t place what you explained.

Thanks Jason!

A.-

Sign in to reply to this post

Jason ByrnesWebAssist

SELECT CompanyInfo.CompanyInfo_Logo, CompanyInfo.CompanyInfo_COName, Jobs.Job_Date, Jobs.Job_Position, Jobs.Job_Salary, Jobs.Job_Department, Jobs.Job_Division, Jobs.Job_City, Jobs.Job_State, Jobs.Job_Contact, Jobs.Job_Email, Jobs.Job_Summary
FROM (Jobs
LEFT JOIN CompanyInfo ON CompanyInfo.ID_User=Jobs.ID_User)
WHERE departments LIKE 'Brokerage%'
ORDER BY Jobs.Job_Date DESC

Sign in to reply to this post

arturo.civit

Originally Said By: Jason Byrnes
  SELECT CompanyInfo.CompanyInfo_Logo, CompanyInfo.CompanyInfo_COName, Jobs.Job_Date, Jobs.Job_Position, Jobs.Job_Salary, Jobs.Job_Department, Jobs.Job_Division, Jobs.Job_City, Jobs.Job_State, Jobs.Job_Contact, Jobs.Job_Email, Jobs.Job_Summary
FROM (Jobs
LEFT JOIN CompanyInfo ON CompanyInfo.ID_User=Jobs.ID_User)
WHERE departments LIKE 'Brokerage%'
ORDER BY Jobs.Job_Date DESC  



Hi Jason thanks a lot, now it works, thanks so much!

Sign in to reply to this post

arturo.civit

Originally Said By: Jason Byrnes
  SELECT CompanyInfo.CompanyInfo_Logo, CompanyInfo.CompanyInfo_COName, Jobs.Job_Date, Jobs.Job_Position, Jobs.Job_Salary, Jobs.Job_Department, Jobs.Job_Division, Jobs.Job_City, Jobs.Job_State, Jobs.Job_Contact, Jobs.Job_Email, Jobs.Job_Summary
FROM (Jobs
LEFT JOIN CompanyInfo ON CompanyInfo.ID_User=Jobs.ID_User)
WHERE departments LIKE 'Brokerage%'
ORDER BY Jobs.Job_Date DESC  



Hi Jason, again, thanks for all the help, I have one question, see, I need now to filter the departments and only print jobs under brokerage and certain departments, for example,

Show only brokerage jobs with Brokerage - System
or
Show only brokerage jobs with Brokerage - Administration

etc, how should I construct the query to have jobs listed only within the requested department? I plan to have 2 pages, one with the department categories where you can click on any and that should be sent as URL parameter like:

list-brokerage-by-category.php?<?php echo $row_rsShowCats['Job_Department']; ?>=Department Here

but the other page, the one that receives that parameter is where I need to construct that query.

Any idea will be greatly appreciated! Thanks!

A.-

Sign in to reply to this post

Jason ByrnesWebAssist

you have the idea of the link backwards

list-brokerage-by-category.php?Department=<?php echo $row_rsShowCats['Job_Department']; ?>

this creates a querystring variable named Department that is given the value of the department name from the recordset.

for the recordset, set the where clause to:
WHERE departments = paramDepartment

then create a new variables as:
name: paramDepartment
Type: Text
Default Value: -1
Run Time Value: $_GET['Department']

Sign in to reply to this post

arturo.civit

Originally Said By: Jason Byrnes
  you have the idea of the link backwards

list-brokerage-by-category.php?Department=<?php echo $row_rsShowCats['Job_Department']; ?>

this creates a querystring variable named Department that is given the value of the department name from the recordset.

for the recordset, set the where clause to:
WHERE departments = paramDepartment

then create a new variables as:
name: paramDepartment
Type: Text
Default Value: -1
Run Time Value: $_GET['Department']  



As usual, thanks so much Jason!

Sign in to reply to this post

Jason ByrnesWebAssist

you're welcome.

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...