Jump to content

Simple php echo/return question...


Thomisback

Recommended Posts

Hi,

 

I'm new here, and beginner at PHP.

I'm trying to return/echo (What's the difference between return and echo?) a specific field from my mysql database and then spit it out using a variable.

I have coded:

<?php
   $row = "therow";
   echo $row['FIELD'] = $FIELD;
   echo "&FIELD=$FIELD";
?>

 

I have coded something wrong and I can't find the error, could anyone help me?

 

Thanks you for your help!

Link to comment
https://forums.phpfreaks.com/topic/84619-simple-php-echoreturn-question/
Share on other sites

you kinda have a few things wrong here.

First, you're defining the $row variable as "therow", then you're re-defining it in an echo statement to equal whatever the $FIELD variable contains (which appears to be nothing), then you're trying to echo some text with the field variable in it.

 

You probably need to do something like

 

<?php 
echo 'Hello World!';
?>

 

then work up:

<?php 
$field='Hello World!';
echo $field;
?>

then perhaps take the array from your database and then do something like:

<?php 
$field=$r['field'];// you need to get the array to put a value in here, though...
$output_variable='&field='.$field; // by the way, you can use the dot (.) to add variables and text stuff together
echo $output_variable;
?>

Hope this helps.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.