Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Newbie: Translate from SQL 1

Status
Not open for further replies.

TheConeHead

Programmer
Aug 14, 2002
2,106
US
Can someone translate this TO MySQL/PHP (it is in ASP/JavaScript:

<%if (!rs.eof) {
if (rs(&quot;fieldName&quot;) == &quot;value&quot;) {%>
<%=rs(&quot;fieldName&quot;)%>
<%}
}%>

Thanks!


[conehead]
 
rs(&quot;fieldname&quot;) would be grabbing the value of the field &quot;fieldname&quot; from the current row (result set)

[conehead]
 
and what are all thos %> signs ??

here
thread434-743971 an example from a mysql query and how to put the data in variables
 
that's asp like <?

I guess what I am wondering is how do I call the value of a field of the current row... If I have a field in my db named &quot;fieldName&quot; how do I grab the current rows value... in asp/SQL I would do <%=rs(&quot;fieldName&quot;)%> and that would print out that fields value

Also, how do I move through my db? in ASP/JavaScript I would do:

rs.MoveNext();

[conehead]
 
I have not figured out if (!rs.eof) but for the rest I think I simply need to use mysql_fetch_array... that seems like it breaks the fields out into an array for individual access... I still need to find out how to move in the db... thanks for your help... I'll look into that one

[conehead]
 
i do not know if rs(&quot;FieldName&quot;) would print all the fileds one by one ar in as associatve array. If i undserstand it correctly u wish to print out then filed name name if it matches ur value.
the look at
mysql_list_fields(dbname, tblname) -- list the filed names

Code:
 $result = mysql_list_fields(dbname, tblname) ;
for ($i = 0; $i < mysql_num_fileds($result); $i++)
{
printf(&quot;Filed name is %s\n&quot;, mysql_field_name($result, $i) ;
printf(&quot;Filed Length is %s\n&quot;, mysql_field_len($result, $i);  printf(&quot;Filed Type is %s\n&quot;, mysql_field_type($result, $i); printf(&quot;Filed Flags is %s\n&quot;, mysql_field_flags($result, $i) ;
}
other options like mysql_fetch_filed and mysql_field_seek may also interest u



[ponder]
----------------
ur feedback is a very welcome desire
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top