| | |
help in sql query
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
hi
i want to fetch username from another table based on the id generated in the temopary table.
i want to fetch username from another table based on the id generated in the temopary table.
PHP Syntax (Toggle Plain Text)
<?php @ $rpp; //Records Per Page @ $cps; //Current Page Starting row number @ $lps; //Last Page Starting row number @ $a; //will be used to print the starting row number that is shown in the page @ $b; //will be used to print the ending row number that is shown in the page if(empty($_GET["cps"])) { $cps = "0"; } else { $cps = $_GET["cps"]; } $a = $cps+1; $rpp = "10"; $lps = $cps - $rpp; //Calculating the starting row number for previous page if ($cps <> 0) { $prv = "<a href='myagreement.php?cps=$lps"."&user1=".$_SESSION['employerid']."'>Previous</a>"; } else { $prv = "<font color='cccccc'>Previous</font>"; } mysql_query("DROP TABLE TEMPORARY IF EXISTS Mytemp"); mysql_query("CREATE TEMPORARY TABLE Mytemp SELECT resumeid,ttdate,ttime from agreements WHERE buyerid='".$_SESSION['employerid']."' order by ttdate DESC"); $q="Select SQL_CALC_FOUND_ROWS * from Mytemp limit $cps, $rpp "; $rs=mysql_query($q) or die(mysql_error()); $nr = mysql_num_rows($rs); //Number of rows found with LIMIT in actiong r $q0="Select FOUND_ROWS()"; $rs0=mysql_query($q0) or die(mysql_error()); $row0=mysql_fetch_array($rs0); $nr0 = $row0["FOUND_ROWS()"]; //Number of rows found without LIMIT in action if (($nr0 < 10) || ($nr < 10)) { $b = $nr0; } else { $b = ($cps) + $rpp; } ?> <br> <table border="0" cellpadding="0" cellspacing="0" width="90%" align="center"> <tr><td><b><font face="verdana" size=2></b></font><b><font face="verdana" size=2 color="#9999CC"></font></b></td></tr> <tr><td align=left colspan="2"><b><font face="verdana" size=1 color="#9999CC"><? echo "$nr0 Records Found"; ?></font></b></td></tr> <tr><td align='left' colspan="2"><b><font face="verdana" size=1 color="#9999CC"><? echo "Showing Records from $a to $b"; ?></font></b></td></tr> </tr> <? $i=$nr0; while ($row=mysql_fetch_array($rs)) { $cps = $cps +1; $idd=$row[2]; $result=mysql_query("SELECT username from login where username='.$idd.'"); while ($line=mysql_fetch_array($result)) { echo "<tr>"; echo "<td>"; echo "<table bgcolor='#fefefe' width='73%' align='center' border='0'>"; echo "<tr><td width='55%'><font face='verdana' size=1><strong>Resume ID : </strong></font><a href='agreement1.php?agreeid=".$row[0]."'>RB".$row[0]."</td><td width='25%'><font face='verdana' size=1><strong>Agreement Signed With</strong></font>$line[0]</td></tr>"; echo "<tr><td width='25%'><font face='verdana' size=1><strong>Date </strong></font>".$row[1]."</td><td width='25%'><font face='verdana' size=1><strong>Time </strong></font>".$row[2]."</td></tr>"; echo "</table>"; echo "</td>"; echo "</tr>"; } echo "<tr><td align='right' colspan=2>$prv"; if ($cps == $nr0) { echo " | <font color='CCCCCC'>Next</font>"; } else { if ($nr0 > 5) { echo " | <a href='myagreement.php?cps=$cps&lps=$lps&user1=".$_SESSION['employerid']."'>Next</a>"; } } ?>
Last edited by cscgal; Mar 4th, 2008 at 1:26 am. Reason: Code tags instead of ICode
How about reposting that and removing all of the PHP and HTML and just post the SQL statements that you want to run along with a description of the originating table.
This might help us to determine what the problem with your particular SQL queries are.
This might help us to determine what the problem with your particular SQL queries are.
JRSofty Programming | .NET Dreaming | GalahTech
If your question is solved then mark the thread solved. If someone gives you good advice then give them some rep.
If your question is solved then mark the thread solved. If someone gives you good advice then give them some rep.
SELECT post_resume.res_title, post_resume.candidate_type, post_resume.owner, post_resume.ind_type, post_resume.career, post_resume.resume, employer.association
FROM post_resume, employer
WHERE post_resume.ind_type = '".$industype."'
AND post_resume.career = '".$careerlevel."'
AND employer.association = 'cg'
AND post_resume.owner != '18'
ORDER BY tdate DESC
sorry for posting all the codes in sql.i want something like the above query.when i tried executing the above query ...all the rows are getting displayed three time.............please do tell me the error
FROM post_resume, employer
WHERE post_resume.ind_type = '".$industype."'
AND post_resume.career = '".$careerlevel."'
AND employer.association = 'cg'
AND post_resume.owner != '18'
ORDER BY tdate DESC
sorry for posting all the codes in sql.i want something like the above query.when i tried executing the above query ...all the rows are getting displayed three time.............please do tell me the error
i tried tat...it is showing error msg
SELECT post_resume.res_title, post_resume.candidate_type, post_resume.owner, post_resume.ind_type, post_resume.career, post_resume.resume, employer.association
FROM post_resume, employer
WHERE post_resume.ind_type = '".$industype."'
AND post_resume.career = '".$careerlevel."'
AND employer.association = 'cg'
AND post_resume.owner != '18'
ORDER BY tdate DESC group by employer.association
SELECT post_resume.res_title, post_resume.candidate_type, post_resume.owner, post_resume.ind_type, post_resume.career, post_resume.resume, employer.association
FROM post_resume, employer
WHERE post_resume.ind_type = '".$industype."'
AND post_resume.career = '".$careerlevel."'
AND employer.association = 'cg'
AND post_resume.owner != '18'
ORDER BY tdate DESC group by employer.association
•
•
Join Date: Apr 2006
Posts: 66
Reputation:
Solved Threads: 11
•
•
•
•
i tried tat...it is showing error msg
SELECT post_resume.res_title, post_resume.candidate_type, post_resume.owner, post_resume.ind_type, post_resume.career, post_resume.resume, employer.association
FROM post_resume, employer
WHERE post_resume.ind_type = '".$industype."'
AND post_resume.career = '".$careerlevel."'
AND employer.association = 'cg'
AND post_resume.owner != '18'
ORDER BY tdate DESC group by employer.association
SELECT post_resume.res_title, post_resume.candidate_type, post_resume.owner, post_resume.ind_type, post_resume.career, post_resume.resume, employer.association
FROM post_resume, employer
WHERE post_resume.ind_type = '".$industype."'
AND post_resume.career = '".$careerlevel."'
AND employer.association = 'cg'
AND post_resume.owner != '18'
GROUP BY employer.association
ORDER BY tdate DESC
Try this by joining the tables using the INNER JOIN....
SELECT * FROM post_resume INNER JOIN employer
ON (post_resume.ind_type = '".$industype."'
AND post_resume.career = '".$careerlevel."'
AND employer.association = 'cg'
AND post_resume.owner != '18')
ORDER BY tdate DESC group by employer.association
Hope this will work!!
SELECT * FROM post_resume INNER JOIN employer
ON (post_resume.ind_type = '".$industype."'
AND post_resume.career = '".$careerlevel."'
AND employer.association = 'cg'
AND post_resume.owner != '18')
ORDER BY tdate DESC group by employer.association
Hope this will work!!
![]() |
Similar Threads
- sql query problem with MS Access and C# (C#)
- Urgent Help with SQL Query (MySQL)
- C# VS 2005 - SQL Query Parameters to an ODBC DataSource (C#)
- sql query updating problem (Visual Basic 4 / 5 / 6)
- Javascript array from sql query (JSP)
- Please help me out with MySQL query (MySQL)
- PHP/SQL query help (PHP)
- Retreiving variables from a sql query into a form (PHP)
Other Threads in the PHP Forum
- Previous Thread: PHPEclipse installation
- Next Thread: Send an Email in PHP
| Thread Tools | Search this Thread |
# 5.2.10 action address apache api array auto autoincrement beginner binary broken cakephp checkbox class classes cms code cron curl database date dehasher destroy display dissertation domain dynamic echo echo$_get[x]changingitintovariable... email error errorlog fatalerror file files folder form forms function functions google href htaccess html if-else image images include insert ip javascript joomla legislation limit link load login mail masterthesis menu mlm multiple mysql mysqlquery oop open paypal pdf persist php popup problem query radio random record recursion remote script search server sessions sms sockets source space sql syntax system table tutorial update upload url validator variable video web youtube





