PHP Echo Back A Form Inside Of A Table Cell - Html - Web Programming

  1. Home
  2. html - PHP Echo back a form inside of a table cell
46 votes 1 answers html - PHP Echo back a form inside of a table cell Get the solution ↓↓↓

Here is how I am echoing back a 'normal' table cell in PHP:

Code:

echo "<tr>"; echo "<td>Some cell data</td>"; echo "</tr>\n"; Copy code

Attempt to echo a button within a cell:

echo "<tr>"; echo "<td><form action="insertdata.php?page=add" method="post"> Username: <input type="text" name="username" > <input type="submit" > </form> </td>"; echo "</tr>\n"; Copy code

Thank you for any help, this is quite confusing to me. I am a beginner when it comes to PHP so please pardon any errors and feel free to kindly correct me wherever a correction is needed!

Undefined asked 2022-02-20 Write your answer 885 votes

Answer

Solution:

You need to either escape your double quotes" that appear inside your string surrounded by double quotes, or use a different quote style (i.e. single quotes') to surround the string that contains the double quotes. It's actually made quite obvious what the problem is by the syntax highlighting on this site.

You could either do this:

echo "<tr>"; echo "<td><form action=\"insertdata.php?page=add\" method=\"post\"> Username: <input type=\"text\" name=\"username\" > <input type=\"submit\" > </form> </td>"; echo "</tr>\n"; Copy code

...or this...

echo "<tr>"; echo '<td><form action="insertdata.php?page=add" method="post"> Username: <input type="text" name="username" > <input type="submit" > </form> </td>'; echo "</tr>\n"; Copy code

I suggest you read this thoroughly so you no what you can and can't legally do with strings in PHP.

As a side note, it is a bad idea to put new-line literals inside quoted strings, as it can lead to cross-platform compatibility wierdness. It's not really a problem with web output like this, but it's a bad habit to get into. You should either use\r,\n and\r\n as appropriate, or if you must put literals into the source code, use heredoc syntax. Remember that escape sequences like\r\n are only interpolated in double quoted strings!!!

Write your answer

Share solution ↓

Additional Information:

Date the issue was resolved: 2022-02-20 Link To Source Link To Answer People are also looking for solutions of the problem: composer detected issues in your platform: your composer dependencies require a php version ">= 8.0.2".

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Similar questions

Find the answer in similar questions on our website.

535 php - Save data to two different tables in CakePHP 3 37 php - File format or extension invalid PHPExcel 162 php - Check if a variable has been set with the name of the value of another variable 343 Add php code to end of every html link 168 Is this an acceptable way to autoload html pages with php? 936 php,mysql,html - Display SQL query(conjunction) properly in HTML 230 Print informative, well formatted mysql errors in PHP 222 PHP + SQL - Using SQL Server 'Create To' scripts to create tables through PHP 724 Including a html form in a php script 167 html - PHP JSON generation problems

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

About the technologies asked in this question

PHP

PHP (from the English Hypertext Preprocessor - hypertext preprocessor) is a scripting programming language for developing web applications. Supported by most hosting providers, it is one of the most popular tools for creating dynamic websites. The PHP scripting language has gained wide popularity due to its processing speed, simplicity, cross-platform, functionality and distribution of source codes under its own license.https://www.php.net/

HTML

HTML (English "hyper text markup language" - hypertext markup language) is a special markup language that is used to create sites on the Internet. Browsers understand html perfectly and can interpret it in an understandable way. In general, any page on the site is html-code, which the browser translates into a user-friendly form. By the way, the code of any page is available to everyone.https://www.w3.org/html/

Welcome to programmierfrage.com

programmierfrage.com is a question and answer site for professional web developers, programming enthusiasts and website builders. Site created and operated by the community. Together with you, we create a free library of detailed answers to any question on programming, web development, website creation and website administration.

Get answers to specific questions

Ask about the real problem you are facing. Describe in detail what you are doing and what you want to achieve.

Help Others Solve Their Issues

Our goal is to create a strong community in which everyone will support each other. If you find a question and know the answer to it, help others with your knowledge.

Latest questions:

487 php - Use mysql_fetch_array() with foreach() instead of while()

841 url - PHP Mod_Rewrite

527 javascript - PHP-SDK for Facebook Connect Generating Error on Logout

439 jquery - execute php/javascript function after a certain amount of time has passed

172 php - Extending CI with own library

255 Comparing mysql dates in php

386 php - One HTTPS ajax call in codeigniter

550 php - iPhone SDK - convert strings to call variable names

435 xml - Translate PHP PUT HTTP request to ColdFusion

470 Get php results with jquery ajax

Users questions:

NEW

mysql

NEW

Warning: Undefined array key "program" in E:\xampp\htdocs\pi\alumni.php on line 27 Warning: Undefined array key "enter_course" in E:\xampp\htdocs\pi\alumni.php on line 31 Warning: Undefined array key "enter_address" in E:\xampp\htdocs\pi\alumni.php on line 32

NEW

Rename existing images with keyword in WordPress PHP

NEW

codeigniter

NEW

Class "web_profiler.controller.profiler" does not exist after upgrading symfony 3.4 to 4.4 version

PHP x 410847Laravel x 36785Yii x 3846CodeIgniter x 9997Symfony x 7793CakePHP x 3085Zend Framework x 1235Phalcon x 300FuelPHP x 47Slim x 570JavaScript x 36883React x 550Angular x 1121Vue.js x 181JQuery x 11108Backbone.js x 21Node.js x 463Ember.js x 10Meteor x 7Polymer x 20Aurelia x 1MySQL x 39074CSS x 2497Bootstrap x 1603Foundation x 84UIkit x 4Semantic UI x 2Bulma x 2Animate.css x 1HTML x 20978

This site uses cookies. We use them to improve the performance of our website and your interaction with it. Confirm your consent by clicking OK

OK

Từ khóa » Echo Tr Td Php