Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MySQL and PHP delima

Status
Not open for further replies.

digatle

Technical User
Oct 31, 2003
85
US
I've started writting the database and PHP to go with it. So far everything is great but I've got a delima.

I have a table called spidernet_application. The way we want the site to work is that there is a Division (6) and Departments under them. I've written it so that blog_id = Division and category_id = Department. That works perfectly. You select say Division 2 and you get a dropdown list of all of Division 2 category's perfectly.

Where my delima comes from though is our applications part. Each Division has its own "global" application set and each Department has their own as well. I've got one table for it called spidernet_application that does them both. But when I say "show me all of the ones with a 2 on them" all of them show up. It's like I need to be able to say something like "If blog=id = 1 and category_id = 901 then display here and if category_id = $category_id (where they are currently like say 37 and there is something there in 37 display it in this table). How do you write that? Here's my code:

<?php
echo $blockopen;
echo $siteID.&quot; Apps.&quot;;
echo $blockbody;
while ($a_row = mysql_fetch_array( $divapp ) ) {
$app_url=$a_row['url'];
$app_image=$a_row['image_location'];
$app_alt=$a_row['description'];
print &quot;<a href=\&quot;$app_url\&quot;><img src=\&quot;$app_image\&quot; alt=\&quot;$app_alt\&quot; border=\&quot;0\&quot;></a><br> &quot;;
}
echo $blockend;
?>

My SQL statement looks like this:

$divapp = mysql_query( &quot;SELECT `blog_id`, `url`, `image_location`, `description` FROM spidernet_applications WHERE `blog_id`=&quot;.$dept.&quot; ;&quot; );

This is probably a simple thing I'm just no well versed in Databases. You'd be surprised all I've learned since posting here. You guys are amazing.

Digatle
 
if you already know the division and department from the drop downs, why not store them in a session and use them in the sql statement to retrieve only those values for that department?



Bastien

Any one have a techie job in Toronto, I need to work...being laid off sucks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top