Hello
Can anyone tell me whether this is correct coding procedure and whether it will work...thanks
I want to perform a query that takes several variables from different places in the database.
I understand that I have to define the variables first and have been using the following code to do so...
$query = "SELECT SectionRef FROM tblUser WHERE CLogIn = '$username'";
$result = mysql_query($query)
or die ("no info");
$row = mysql_fetch_array($result);
$SectionRef = $row["SectionRef"];
Here I have the $username information from a login form on the first page and I can use that information to get the SectionRef variable from the User table....
However can I then run a second query in the same format using the $SectionRef to get another variable e.g.
$query = "SELECT MachineId FROM tblMachine WHERE SectionRef = $SectionRef";
$result1 = mysql_query($query)
or die ("no Machine info");
$row1 = mysql_fetch_array($result1);
$MachineRef = $row1["MachineId"];
And then can I use the Machine Ref as part of a bigger query, that uses $username, $MachineRef and results from a form on the previous page to INSERT info into the database?
Is it correct coding to run subsequent queries in this way to gather information that will be recognised later in the script?
ALSO (!) can anyone see why I keep getting a parse error on this script, it shows an error on the first line of the second query :-
$query = "SELECT MachineId FROM tblMachine WHERE SectionRef = $SectionRef";
thanks to you all in advance..........