News Register Control Panel Private Messages Members List Team Search News Posts About Us

Linux Advisory » Q & A - Discussions » Programming & Coding » PHP&Mysql Problem » Hello Guest [login|register]
Last Post | First Unread Post Print Page | Recommend to Friend | Add Thread to Favorites
Post New Thread Post Reply
Author
Post « Previous Thread | Next Thread »
Telos Telos is a Male
Super Moderator


Registration Date: 06-04-2003
Posts: 130
Location: Finland
Linux Distro: hmm....

Rating:
3 Votes - Average Rating: 7.00

Level: 19 [?]
Experience Points: 18.489
Next Level: 22.851
4.362 point(s) of experience needed for next level

OFFLINE

PHP&Mysql Problem Post Reply with Quote Edit/Delete Post Report Post to a Moderator       IP Information

Ok, here's the situation:
I'm creating a research system and I have among others an answer, profile, profileformula and answerer tables. Profiles are there to profilize answerers like this:

Profile: List all under 25 years old females.
ProfileFormulas related to this profile are:
question AGE < 25
question GENDER = female

I have a problem related to reporting and showing all answerers in different profiles. I can do it if a profile has only 1 profileformula but I need it to work with more. So now I do it like this.

1. I get all the profile id's which are related to specific research
2. Then I get all the profileformulas which are related to specific profile.
3. I get all the answerers from the answers table where the answer is according to the formula
4. I get the answerer details according to the answerer id which I got from the last query.

This doesn't work if there are more than 1 profileformula in pne profile. So I've thought the following solution

1. When I get the answerer id's like in stage 3 earlier I put the to array so the array has all the user id's which full the first profileformula.
2. When I start to check the next formula I go through the array and if the id which I get from the second formula check is on the array I mark it as checked. When the query array has gone through I delete all the names from the array which are not checked.
4. I continue until I've gone through all the profileformulas and as a result I have an array which has all the id's of such answerers who fullfill all the profileformula requirements.

The problem is that I don't know how to code this? Anyone can help? here's the report.php code as it is at the moment so maybe that will clear things a bit for you.

php:
<?php
session_start
();

// Tarkistetaan onko käyttäjä sisäänkirjautunut ja omaa tarvittavat käyttöoikeudet
if($_SESSION['sessio_sukunimi'] == '')
  
header('location: login.php');
if(
$_SESSION['sessio_kayttajataso'] < 5)
  
header('location: insufficient_userlevel.php');

// Haetaan käyttäjän valitsema teema
if($_SESSION['sessio_theme'] == '')
  
$theme 'default';
else
  
$theme $_SESSION['sessio_theme'];


include(
'sivupohjat/'.$theme.'_header.php');


// Otetaan parametrit vastaan
$tutkimus_id $_GET['tutkimus'];

dbConnect();
$sql mysql_query("SELECT id, nimi, kuvaus FROM ir_profiili WHERE tutkimus = $tutkimus_id");
while(
$result mysql_fetch_array($sql))
{
$profiili_id $result['id'];
$profiili_nimi $result['nimi'];
$profiili_kuvaus $result['kuvaus'];

echo(
"PROFIILI: <b>$profiili_nimi</b><br>$profiili_kuvaus<br><br>");

// Kun tiedetään profiili_id niin haetaan kaavat tuolle id:lle
$sql2 mysql_query("SELECT kysymys, operaattori, vertailu FROM ir_profiilikaavat WHERE profiilitunnus = $profiili_id");
while(
$result2 mysql_fetch_array($sql2))
{
$kysymys $result2['kysymys'];
$operaattori $result2['operaattori'];
$vertailu $result2['vertailu'];

// Haetaan vastaajat jotka ovat profiilin mukaisia
echo("<ul type=\"disc\">");
$sql3 mysql_query("SELECT DISTINCT vastaaja FROM ir_vastaus WHERE kysymys = $kysymys AND vastaus $operaattori '$vertailu' AND vastaus != ''");
while(
$result3 mysql_fetch_array($sql3))
{
$vastaaja_id $result3['vastaaja'];

// Kun tiedetään vastaajatunnus niin voidaan hakea vastaajan tiedot vastaajataulusta
$sql4 mysql_query("SELECT etunimi, sukunimi, email FROM ir_vastaaja WHERE id = '$vastaaja_id'");
$result4 mysql_fetch_array($sql4);
$etunimi $result4['etunimi'];
$sukunimi $result4['sukunimi'];
$email $result4['email'];

echo(
"<li><b>$sukunimi, $etunimi</b>    <a href=\"mailto:$email\" title=\"Mailaa\">$email</a></li>");

}
echo(
"</ul>");
echo(
"<br>");
}
}
include(
'sivupohjat/'.$theme.'_footer.php');
?>



07-31-2003 11:18 Send an Email to Telos Homepage of Telos Search for Posts by Telos Add Telos to your Buddy List Add Telos to your Contact List AIM Screenname: dreamimpactcom
Heather Heather is a Female
Respected Member




Registration Date: 05-21-2003
Posts: 511
Location: Lost City of Zen.
Linux Distro: I'm OS neutral.

Rating:
9 Votes - Average Rating: 3.67

Level: 25 [?]
Experience Points: 79.578
Next Level: 100.000
20.422 point(s) of experience needed for next level

OFFLINE

Post Reply with Quote Edit/Delete Post Report Post to a Moderator       IP Information

Telos, I don't know the answer to your question myself...but I guarantee you the folks over at this site have an answer. A lot of them live and dream php. Smile

Good luck!



Utinam logica falsa tuam philosophiam totam suffodiant

08-02-2003 08:10 Send an Email to Heather Search for Posts by Heather Add Heather to your Buddy List
Telos Telos is a Male
Super Moderator


Registration Date: 06-04-2003
Posts: 130
Location: Finland
Linux Distro: hmm....

Rating:
3 Votes - Average Rating: 7.00

Level: 19 [?]
Experience Points: 18.489
Next Level: 22.851
4.362 point(s) of experience needed for next level

OFFLINE

Post Reply with Quote Edit/Delete Post Report Post to a Moderator       IP Information

Thanx for the tip. I'll post this there and see what they can come up with.



08-02-2003 14:57 Send an Email to Telos Homepage of Telos Search for Posts by Telos Add Telos to your Buddy List Add Telos to your Contact List AIM Screenname: dreamimpactcom
Heather Heather is a Female
Respected Member




Registration Date: 05-21-2003
Posts: 511
Location: Lost City of Zen.
Linux Distro: I'm OS neutral.

Rating:
9 Votes - Average Rating: 3.67

Level: 25 [?]
Experience Points: 79.578
Next Level: 100.000
20.422 point(s) of experience needed for next level

OFFLINE

Post Reply with Quote Edit/Delete Post Report Post to a Moderator       IP Information

No problem Telos.



Utinam logica falsa tuam philosophiam totam suffodiant

08-02-2003 15:27 Send an Email to Heather Search for Posts by Heather Add Heather to your Buddy List
onzeponze onzeponze is a Male
Lord


Registration Date: 06-17-2003
Posts: 384
Location: India
Linux Distro: Knoppix

Rating:
6 Votes - Average Rating: 3.83

Level: 23 [?]
Experience Points: 49.557
Next Level: 62.494
12.937 point(s) of experience needed for next level

OFFLINE

Post Reply with Quote Edit/Delete Post Report Post to a Moderator       IP Information

You might want to try phpfreaks.com, they're bound to help you too.

08-04-2003 10:09 Send an Email to onzeponze Search for Posts by onzeponze Add onzeponze to your Buddy List
Telos Telos is a Male
Super Moderator


Registration Date: 06-04-2003
Posts: 130
Location: Finland
Linux Distro: hmm....

Rating:
3 Votes - Average Rating: 7.00

Level: 19 [?]
Experience Points: 18.489
Next Level: 22.851
4.362 point(s) of experience needed for next level

OFFLINE

Post Reply with Quote Edit/Delete Post Report Post to a Moderator       IP Information

The phpfreaks.com owner is at the forum which link Heather gave me so I guess it's the same.



08-04-2003 10:39 Send an Email to Telos Homepage of Telos Search for Posts by Telos Add Telos to your Buddy List Add Telos to your Contact List AIM Screenname: dreamimpactcom
onzeponze onzeponze is a Male
Lord


Registration Date: 06-17-2003
Posts: 384
Location: India
Linux Distro: Knoppix

Rating:
6 Votes - Average Rating: 3.83

Level: 23 [?]
Experience Points: 49.557
Next Level: 62.494
12.937 point(s) of experience needed for next level

OFFLINE

Post Reply with Quote Edit/Delete Post Report Post to a Moderator       IP Information

hmm, i didnt know that, sorry for posting the link.

08-04-2003 10:44 Send an Email to onzeponze Search for Posts by onzeponze Add onzeponze to your Buddy List
Telos Telos is a Male
Super Moderator


Registration Date: 06-04-2003
Posts: 130
Location: Finland
Linux Distro: hmm....

Rating:
3 Votes - Average Rating: 7.00

Level: 19 [?]
Experience Points: 18.489
Next Level: 22.851
4.362 point(s) of experience needed for next level

OFFLINE

Post Reply with Quote Edit/Delete Post Report Post to a Moderator       IP Information

that's ok...how you could you know that Smile I just stated that I'll probably get all the help from the Heather's link and I don't have need to go elsewhere.



08-04-2003 10:59 Send an Email to Telos Homepage of Telos Search for Posts by Telos Add Telos to your Buddy List Add Telos to your Contact List AIM Screenname: dreamimpactcom
Post Reply:
Title (Optional):
Message:


Convert URLs: Automatically converts internet addresses into links by adding [url] and [/url] around them.
Email Notification: Notifies you by email every time there is a new post in this thread.
Deactivate smilies in this post.
Add Signature: Displays your signature in this post.


Tree Structure | Board Structure
Post New Thread Post Reply
Go to:


Powered by Burning Board 2.0.2 © 2001-2002 WoltLab GbR
English Translation by Satelk