Senior & Expert PHP Developers Discussion Forum by Nyros Technologies

HIRE PHP Expert Developers Programmers Coders From India
PHP .Net Ruby on Rails Developers Community, Nyros Technologies, Kakinada
 
Log in  or IF not a member please REGISTER
Username:
Password:   


Keyword
Log in | Profile 

query in many table..how to read it

 
Post new topic   Reply to topic    Senior & Expert PHP Developers Discussion Forum by Nyros Technologies Index -> Sessions Management
View previous topic :: View next topic  
Author Message
mun



Joined: 14 Mar 2010
Posts: 2

PostPosted: Sun Mar 14, 2010 8:03 am    Post subject: query in many table..how to read it Reply with quote

1) Can php can search data in more table in database

2)I need help from you all to check my PHP code. I have try to run the code but it doesn't display the result. I have try to use only2 table query and it display the result but went I try to add the third query it doesn't display the result. Below is the php code that I use.Hope anyone here can help me..


<?php
include "config.php";
?>
<?php

//if (isset ($_POST['Submit']) == "Submit") {
$bmGrade = $_POST['bmGrade'];
$biGrade = $_POST['biGrade'];
$mathGrade = $_POST['mathGrade'];
$snGrade = $_POST['snGrade'];
$geoGrade = $_POST['georade'];
$sejGrade = $_POST['sejGrade'];
$khGrade = $_POST['khGrade'];
$piGrade = $_POST['piGrade'];
$question1 = $_POST['question1'];
$question2 = $_POST['question2'];
$question3 = $_POST['question3'];

//set up the query
$query1="select * from rules1 where bmGrade = '".$_REQUEST['bmGrade']."' and biGrade='".$_REQUEST['biGrade']."' and snGrade='".$_REQUEST['snGrade']."' and mathGrade='".$_REQUEST['mathGrade']."' and khGrade='".$_REQUEST['khGrade']."' and piGrade='".$_REQUEST['piGrade']."' and sejGrade='".$_REQUEST['sejGrade']."' and geoGrade='".$_REQUEST['geoGrade']."' and question1='".$_REQUEST['question1']."' and question2='".$_REQUEST['question2']."' and question3='".$_REQUEST['question3']."'";

$query2="select * from rules2 where bmGrade = '".$_REQUEST['bmGrade']."' and biGrade='".$_REQUEST['biGrade']."' and snGrade='".$_REQUEST['snGrade']."' and mathGrade='".$_REQUEST['mathGrade']."' and khGrade='".$_REQUEST['khGrade']."' and piGrade='".$_REQUEST['piGrade']."' and sejGrade='".$_REQUEST['sejGrade']."' and geoGrade='".$_REQUEST['geoGrade']."' and question1='".$_REQUEST['question1']."' and question2='".$_REQUEST['question2']."' and question3='".$_REQUEST['question3']."'";

$query3="select * from rules3 where bmGrade = '".$_REQUEST['bmGrade']."' and biGrade='".$_REQUEST['biGrade']."' and snGrade='".$_REQUEST['snGrade']."' and mathGrade='".$_REQUEST['mathGrade']."' and khGrade='".$_REQUEST['khGrade']."' and piGrade='".$_REQUEST['piGrade']."' and sejGrade='".$_REQUEST['sejGrade']."' and geoGrade='".$_REQUEST['geoGrade']."' and question1='".$_REQUEST['question1']."' and question2='".$_REQUEST['question2']."' and question3='".$_REQUEST['question3']."'";

//run the query and get the number of affected rows
$result1 = mysql_query($query1) or die(mysql_error());
$result2 = mysql_query($query2) or die(mysql_error());
$result3 = mysql_query($query3) or die(mysql_error());

$num_rows1 = mysql_num_rows($result1);
$num_rows2 = mysql_num_rows($result2);
$num_rows3 = mysql_num_rows($result3);

if ($num_rows1 == 0)
{
$finalResult = $result2;
} //end if

elseif ($num_rows2==0 && $num_rows1 == 0 )
{
$finalResult = $result3;
}

else //if num_rows1 != 0
{
$finalResult = $result1;
} //end else

while ($row = mysql_fetch_assoc($finalResult))
{
session_start();
$result_ID1=mysql_query($query1);
$result_ID2=mysql_query($query2);
$result_ID3=mysql_query($query3);

if(mysql_num_rows($result_ID1)==0)
{
$row=mysql_fetch_assoc($result_ID2);

$_SESSION['result1'] = $row['result1'];
$_SESSION['result2'] = $row['result2'];
$_SESSION['result3'] = $row['result3'];
$_SESSION['bestResult'] = $row['bestResult'];


header('Location: result_recommendation.php');
}

elseif (mysql_num_rows($result_ID2)==0 && mysql_num_rows($result_ID1)==0)
{
$row=mysql_fetch_assoc($result_ID3);

$_SESSION['result1'] = $row['result1'];
$_SESSION['result2'] = $row['result2'];
$_SESSION['result3'] = $row['result3'];
$_SESSION['bestResult'] = $row['bestResult'];


header('Location: result_recommendation.php');
}

else
{
$row=mysql_fetch_assoc($result_ID1);

$_SESSION['result1'] = $row['result1'];
$_SESSION['result2'] = $row['result2'];
$_SESSION['result3'] = $row['result3'];
$_SESSION['bestResult'] = $row['bestResult'];

header('Location: result_recommendation.php');
}
}//end while
?>
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Senior & Expert PHP Developers Discussion Forum by Nyros Technologies Index -> Sessions Management
Page 1 of 1

 latest topics 
 Topics   Replies   Author   Views   Last Post 
No new posts How to download a multiple files from server to localhost
0 rajkumar 15 Thu Sep 09, 2010 5:23 am
rajkumar View latest post
No new posts How to transfer a file from localhost to server using ssh
0 rajkumar 15 Thu Sep 09, 2010 5:15 am
rajkumar View latest post
No new posts How to download a file from server to localhost using ssh
0 rajkumar 15 Thu Sep 09, 2010 5:02 am
rajkumar View latest post
No new posts How to select limited sites in addthis share
0 rajkumar 27 Wed Sep 08, 2010 7:16 am
rajkumar View latest post
No new posts Capitalize First Letter Of Every Sentence in php
0 rajkumar 19 Wed Sep 08, 2010 5:47 am
rajkumar View latest post
No new posts seo test
1 admin 323 Tue Sep 07, 2010 10:54 am
chrisadam View latest post
No new posts How to change joomla urls as SEO friendly
2 aababu 178 Tue Sep 07, 2010 10:50 am
chrisadam View latest post
No new posts Passing numeric as a string
0 holepro 45 Sun Sep 05, 2010 3:55 pm
holepro View latest post
No new posts How to call cross domain requests in ajax using php
1 Sanjana 59 Fri Sep 03, 2010 10:54 am
AnilKumar View latest post
No new posts how to delete plugins in openinviter
2 aababu 280 Wed Sep 01, 2010 7:27 am
aartylamba View latest post





Hire an expert PHP developer / coder / programmer or development team from India now!!

Other Forums : Ruby on Rails   ::   .Net   |   Free unlimited HTML CSS Joomla Wordpress Drupal templates download

Nyros Technologies   |   Developers Blog   |   Kakinada City Portal   |   About PHP Experts   |   More