|
Posted by Jerry Stuckle on 10/08/06 18:52
Garry Jones wrote:
> "Mateusz Markowski" <mateusz@bsdmail.org> skrev i meddelandet
> news:1160322153.961306.179050@k70g2000cwa.googlegroups.com...
>
>
>>You should have written:
>
>
>>$upgcollect="SELECT scfpwd1 FROM scfmforening WHERE scfmnum =
>>$scfchknum";
>
>
> No, I still can not get this working.
>
> The examples on the net are complex and I can not deduce the simple line of
> code that I need from them
>
> This is the problem. Put simply
>
> $var1=$_POST['anum'];
> (inlogging mysql)
> $var2="SELECT field2 FROM table1 WHERE field4 = $var1";
> (logout mysql)
> mysql_close();
>
> (Need help with necessary code to assign variable $var2 to the value of
> field4 for the record where users value is found)
>
> I can not use the row index as that is assigned to another sequential value
> and unknown to the user.
>
> For instance
>
> A table (table1) with the following fields
>
> index, field2, town, townnum
>
> Records of
> 1 abc dallas 5
> 2 def denver 3
> 3 ghh atlanta 17
> 4 gfe gateshead 24
>
> The user knows the townnumber (5 or 8 or 17 or 24). The user does not know
> the index, but townnum will always have a unique value.
>
> He keys in his number.
>
> I then want to look for the value of field 2 in the record where the user's
> townnumber was found.
>
> I then want to assign a variable to the value of the field2 in that record
>
> If he types in 3 my code should assign the value of def to $var2
>
> I understand its a combination of select, query and result but need help
> with the syntax.
>
> Any help greatly appreciated.
>
> Garry Jones
> Sweden
>
>
>
>
>
>
>
Garry,
$var2 is just a string. You have made no call to MySQL.
Once you have the SQL statement, you must pass it to mysql_query() to
query the database. Then check the result (which is a result set, not
the data itself); false indicates an error.
If there is no error, you must call mysql_fetch_array() or
mysql_fetch_result() to retrieve the actual data.
See the PHP manual for more information.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Navigation:
[Reply to this message]
|