View Full Version : please help me its urgent :((((((
littlegirl
08-22-2005, 05:38 PM
please tell me how i can do this :
i have 2 tables:
student
id_student
name_student
Lname_student
ID_drejtimi
year_studing
drejtimet
ID_drejtimi
Name
i have even a from in wich i choose the year in wich the student is and the "drejtimi"(this is a field that tells if student its for inforatic, telecom or electronic ) based on this i have to generate a table with all studnts lets say of first year , telecomunication .
the query that i did is this :
Quote:
<?$query= "select *from student,drejtimet where drejtimet.Name='$Drejtimi' and student.year_studing='$Vit' and drejtimet.ID_drejtimi=student.ID_drejtimi order by student.name_studnet ";?>
the result that i take from this query is an ampty table .... may u help me please
NancyJ
08-22-2005, 05:58 PM
Try:
$query = "SELECT student.*, drejtimet.* FROM student.*
INNER JOIN drejtimet ON
student.ID_drejtimet = drejtimet.ID_drejtimet
WHERE drejtimet.Name = '$Drejtimi' AND student.year_studying = '$Vit'
ORDER BY student.name_student"
You might also want to echo your query to check the dynamic elements are being filled in correctly and check your db to see that the data you're looking for actually exists
littlegirl
08-22-2005, 11:16 PM
ok i try yr query but i get this warning :
Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in D:\xampp\htdocs\upt\kerkostudent.php on line 46
i am sending u the piece of code that i have done , maybe u can help me :( its very important for me to solve this problem. sorry if some words r not in english (there r in albania)
<?
$query= "SELECT studentet.*, drejtimet.* FROM studentet.*
INNER JOIN drejtimet ON
studentet.ID_Drejtimi = drejtimet.ID_Drejtimi
WHERE drejtimet.Emer = '$Drejtimi' AND studentet.Viti_Aktual = '$Vit'
ORDER BY studentet.Emer" ;
$queryall = $query;
mysql_query($queryall);
$resultall = MYSQL_QUERY($queryall);
$numberall = mysql_Numrows($resultall);
$x = 0;
while ($x<$numberall)
{
if (($x%2)==0) { $bgcolor="#FFFFFF"; } else { $bgcolor="#E6D9E6"; }
$Emer=mysql_result($resultall,$x,"studentet.Emer");
$Mbiemer=mysql_result($resultall,$x,"studentet.Mbiemer");
$Viti_Aktual=mysql_result($resultall,$x,"studentet.Viti_Aktual");
?>
<tr bordercolor="#006699" bgcolor="<? echo $bgcolor; ?>">
<td height="16">
<? echo "<strong><font size=\"2\" face=\"Arial, Helvetica, sans-serif\" text color= \"005680\"> $Emer </strong> </font>" ?>
</td>
<td height="16">
<? echo "<strong><font size=\"2\" face=\"Arial, Helvetica, sans-serif\" text color= \"005680\"> $Mbiemer </strong> </font>" ?>
</td>
<td height="16">
<? echo "<strong><font size=\"2\" face=\"Arial, Helvetica, sans-serif\" text color= \"005680\"> $Viti_Aktual </strong> </a></font>" ?>
</td>
<td height="16">
<div align="left"><font size="2" color="#FF0000" face="Geneva, Arial, Helvetica, sans-serif"><? echo "<a href=\"update1.php?ID_Student=$ID_Student\">X</a>" ?>
</font></div>
</td>
</tr>
<?
$x++;
} // mbaron while
?>
please help me :(
Kid Charming
08-23-2005, 02:56 AM
In your query, you should have 'FROM studentet' instead of 'FROM studentet.*'. When debugging queries in PHP, mysql_error() is an invaluable tool; it will give you the error from the database:
$result = mysql_query($query) or die(mysql_error());
Also, you don't need to call mysql_query() twice. Remove the one that's not feeding a variable.
littlegirl
08-23-2005, 01:35 PM
this query is driving me crazy ... ok the error that i get is this one :
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM studentet INNER JOIN drejtimet ON studentet.ID_Drejtimi = drejtimet.ID_D' at line 1
please help me to solve this probelm :eek:
Kid Charming
08-23-2005, 06:40 PM
Can you echo your $query variable and post the result?
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.