• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

really quick question w/ SQL/ php

zimu

Diamond Member
mods please allow this to stay alive until i get a response, then feel free to transfer!

ok, so, SQL query:

select accounts as accountname from theaccounts where id = 5

how do i access the "accountname" variable?

i remember somethign about $<queryname>.accountname but that doesn't work.
 
$query = mysql_query("select accounts as accountname from theaccounts where id = 5");
$row = mysql_fetch_row($query);

echo $row[0];
 
$query = "select accounts as accountname from theaccounts where id = 5";
$connection = mysql_connect(/*Your host*/, /*Your username*/, /*Your password*/);
mysql_select_db(?*the database*/, $connection);
$results = mysql_query($query,$connection);

$accountname = mysql_result($results,0,"accountname");

Now you can access the field through $accountname
like say

print $accountname;
 
Originally posted by: jonmullen
$query = "select accounts as accountname from theaccounts where id = 5";
$connection = mysql_connect(/*Your host*/, /*Your username*/, /*Your password*/);
mysql_select_db(?*the database*/, $connection);
$results = mysql_query($query,$connection);

$accountname = mysql_result($results,0,"accountname");

Now you can access the field through $accountname
like say

print $accountname;

yeah thats how i was thinking of doing it. for some reason i just remember an easier way where you could directly access it. i know you can do that with cold fusion, the variable is simply #queryname.accountname#, i was hoping php would have the same. oh well, have to do it the long way!

thanks for the help guysl
 
Back
Top