Jump to content

PHP Variables in MySQL


crochk

Recommended Posts

I am making a site to allow a swim school to generate the comments for report cards from a list from a MySQL database.

 

The instructor enters the students name and then the database displays all the comment lines from the database with the name filled in.  I have the name set to the variable $first and in the database everywhere I want it to display the name I wrote $first.

 

Here is the line from the php page:

while($row = mysql_fetch_array($select))
	{
	echo "<h1>POSITIVE INTRO COMMENTS</h1>";
	echo $row['sentence'];
	}

Then in the database the sentence is:

It has been a very productive session for $first

 

Any help will be much appreciated

Link to comment
https://forums.phpfreaks.com/topic/167041-php-variables-in-mysql/
Share on other sites

why don't you remove the variable $first from the database and then add the variable later?

 

So the sentence should be:

It has been a very productive session for

 

and the code should be:

while($row = mysql_fetch_array($select))
      {
      echo "<h1>POSITIVE INTRO COMMENTS</h1>";
      echo $row['sentence'] . "$first";
      }

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.