Jump to content

Recommended Posts

Posted

Very simple php script:

 

$result = mysql_query("SELECT id, fullname FROM mdl_course");

while($row = mysql_fetch_array($result))

{

echo $row['id'] . " " . $row['fullname'];

echo "

";

}

?>

 

But I want to change it so that I can write 'id' and 'fullname' into

 

Something like:

 

$row['fullname']

 

Can anyone help?

Posted

Either use single quotes and drop out of the string to pull in the variables; or use double quotes, escape the ones you want echo'd out, and use curly braces to pull in the variables.

 

Method 1

 

echo '' . $row['fullname'] . '';

 

Method 2

 

echo "{$row['fullname']}";

  • Thanks 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...