Link to home
Create AccountLog in
Avatar of Chris Andrews
Chris AndrewsFlag for United States of America

asked on

php/mysql help needed

I've got the code below. It works, but I am wondering if there is a more efficient way to do it. I use the variables in various places in the script. Would it be more effiecient to just use the array values, ie: $info[4], instead of assigning it?

Should I somehow be able to just refer to these by the mysql field names they are in, and would that be better?

Thanks,  Chris

(ps: it does just fetch one row, never more)

------------------------------

$result = mysql_query("SELECT * FROM share WHERE author = '$author'");
$info = mysql_fetch_row($result);

$count = $info[1];
$share = $info[4];
$pub = $info[5];
$slot1 = $info[6];
$slot2 = $info[7];
$track1 = $info[8];
$track2 $info[9];
ASKER CERTIFIED SOLUTION
Avatar of gamebits
gamebits
Flag of Canada image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
also,

$result = mysql_query("SELECT * FROM share WHERE author = '$author'");
$info = mysql_fetch_array($result, MYSQL_ASSOC);

echo "".$info['fieldname']."";
Avatar of Chris Andrews

ASKER

Thank you both, this seems to work well :)