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 About foxycart
0 venkatadapa 5 Fri Jul 30, 2010 10:02 am
venkatadapa View latest post
No new posts How to change the mysql storage engine from MyISAM to innodb
1 aababu 10 Fri Jul 30, 2010 9:57 am
venkatadapa View latest post
No new posts How can we increase the execution time of a php script?
0 samir 6 Fri Jul 30, 2010 4:15 am
samir View latest post
No new posts Get no of days between two dates & current dates using M
0 samir 4 Fri Jul 30, 2010 4:09 am
samir View latest post
No new posts What are the different types of errors in php
0 samir 6 Fri Jul 30, 2010 4:00 am
samir View latest post
No new posts How to remove a value in an array using javascript
0 samir 10 Thu Jul 29, 2010 7:27 am
samir View latest post
No new posts Agile methodology plays vital role in software development
0 venkatadapa 7 Thu Jul 29, 2010 7:20 am
venkatadapa View latest post
No new posts How to get complete information about $_SERVER variable
0 Sanjana 15 Wed Jul 28, 2010 6:58 am
Sanjana View latest post
No new posts DNL Reader for php website
0 Mike 22 Mon Jul 26, 2010 12:33 pm
Mike View latest post
No new posts Use mysql_real_escape_string() function to avoid mysql injec
0 venkatadapa 26 Mon Jul 26, 2010 11:05 am
venkatadapa 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