•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 403,397 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,648 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 648 | Replies: 12
![]() |
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
@ $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 12:26 am. Reason: Code tags instead of ICode
•
•
Join Date: Dec 2007
Location: Somewhere in Germany
Posts: 53
Reputation:
Rep Power: 1
Solved Threads: 9
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.
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:
Rep Power: 3
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
try:
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!!
![]() |
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
ajax asp database decimal seperator thousand seperator when using sql server deleting records from ms sql table where columns have duplicate values developer development hacker management studio 2005 microsoft msdn news office security software sql sql cache dependency with polling-based invalidation survey vista
- 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


Linear Mode