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
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.