473,499 Members | 1,533 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How can I include a file betweeen <td> tag?

How do i achieve the echo "include part in the code? I am getting an error.
Expand|Select|Wrap|Line Numbers
  1. <?php 
  2. mysqli_select_db($connect, "developers"); 
  3.  
  4. $result = mysqli_query($connect, "SELECT * FROM finddev");
  5. echo "<table border='1'>
  6. <tr>
  7. <th>Serial</th>
  8. <th>Application</th>
  9. <th>Developer</th>
  10. <th>Platform</th>
  11. <th>Website</th>
  12. <th>Reviews</th>
  13. </tr>";
  14.  
  15. while($row = mysqli_fetch_array($result))
  16.   {
  17.   echo "<tr>";
  18.   echo "<td>" . $row['Serial'] . "</td>";
  19.   echo "<td>" . $row['Application'] . "</td>";
  20.   echo "<td>" . $row['Developer'] . "</td>";
  21.   echo "<td>" . $row['Platform'] . "</td>";
  22.   echo "<td>" . $row['Website'] . "</td>";
  23.   echo "<td>" . include 'review.php' . "</td>"; -- This part
  24.   echo "</tr>";
  25.   }
  26.  
  27.  
  28. echo "</table>";
  29.  
  30.  
  31. ?>
  32.  
Nov 7 '10 #1
2 2194
Cmaza
16 New Member
I haven't double-checked or tested this, but off the top of my head, I think the problem is the context in which you're calling include. Might not be it, but, I don't think it looks right - Include parses and executes rather than parsing and returning. Anyhow.

Where you've got:

echo "<td>" . include 're.php' . "</td>";

Instead, try this:

echo "<td>"; include "re.php"; echo "</td>";

(And whatever you're wanting to be returned from 're.php', just add another echo in the actual file where said returning data is - it'll execute within the correct scope).

If it works, problem solved; If not, just reply again to let us know. ^.^
Nov 7 '10 #2
Atli
5,058 Recognized Expert Expert
Hey.

That depends on what is in the file you are trying to include. If it is just a normal PHP file, without a global return statement, you would have to include it in a separate statement.
Expand|Select|Wrap|Line Numbers
  1. echo "<td>";
  2. include 'review.php';
  3. echo "</td>";
  4.  
The include command essentially imports the contents of the file you point to into the current file. An easy way to think about it is that it copy/pastes the code from the file over the include command.

So if the 'review.php' file contained something like this:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $m = 42;
  3. $c = 3.14159;
  4. $e = $m * pow($c, 2);
  5. echo "From review.php: $e";
  6. ?>
The effective outcome, after the include, would be:
Expand|Select|Wrap|Line Numbers
  1. echo "<td>";
  2. $m = 42;
  3. $c = 3.14159;
  4. $e = $m * pow($c, 2);
  5. echo "From review.php: $e";
  6. echo "</td>";
  7.  
There are other uses of the include command, when coupled with global return statements, so look out for that.
Nov 7 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
689
by: Matt Adams | last post by:
I want to move the following <PRE> defintion to a css file: <TABLE><TR><TD><PRE>sample text</PRE></TD> <TD> not predefined font</TD></TR></TABLE> should be <TABLE><TR><TD class=aaa>sample...
2
11181
by: js | last post by:
I have a table rendered with XSLT. The first column has a radio button controls for user to make a selection for a particular row. All the values in the remaining columns are all concated with a...
2
5743
by: bissatch | last post by:
Hi, I am trying to use JavaScript to write a table column on a web page. The code is as follows: <html> <head> <script> function displaycount() {
3
1689
by: RC | last post by:
I have a very sime html table like <html><head><title>My Table</title> <style> input { margin: 0; padding: 0; border-width: 0; text-indet: 0; text-align: left } </style></head><body> <table...
3
5423
by: Henry Johnson | last post by:
Okay - I'm spinning my wheels on this one... can someone help me figure out how to programmatically populate a table cell as follows (from C# code-behind)? I've tried using a Literal control in the...
5
4446
by: Steel | last post by:
Hi at all, I have a table into my css file I wrote: td{vertical-align:top;} But I want that a certain image be at the bottom of my <td> How can I do please? Regards Steel
5
2926
by: mahesr | last post by:
I want to match some particular text between <tr>and </tr> or <td>and </td>.... in PHP. like below............ <table><tr> CATEGORY: <td><font face="Verdana" size="1" color="#A000A0"> Wedding...
4
5239
George Lft
by: George Lft | last post by:
I'm new at building table. Mostly PHP programming . Now I can't seem to fix the size of my table row and column. Any idea? <h4>Two rows and three columns:</h4> <table border="1"> <tr> ...
7
2772
by: Xiaoyan | last post by:
Hi,everyone: I have a problem now. I can't get the information between the <tr><td> and </td></tr>. for example: I use this regular expression can't get it, I don't know why....
4
3593
by: ismailc | last post by:
Good day, RamananKalirajan helped me with a great script to do a popup div. The problem i now have is that the popup div within the div does not like any table><tr><td>, so itried using <div> in...
0
7130
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7007
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7171
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6893
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7386
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5468
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4599
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3098
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1427
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.