PHP help . HTACCESS FILE?
-
i have a page home.php and i im trying to displays records in a table but it never works except i create the table inside the php code(<php? echo "<table">; echo "<tr><td>"; echo $name") but i dont like it this way its too stressful repeating the echo all the way , i want to display the records like this <table><tr><td><? echo $name; ?></td</tr></table>. I read some article online about creating .htaccess and making some changes to your http.conf files but i dnt understand any. I really need your help you guyz on what to do. Im using dreamweaver cs3 and wamp5 for my site, hope this is enough for you guyz, thanks for your help.
-
Answer:
you need to close down the php before starting the table, and reopen it after, like this: ?> <table><tr><td><? echo $name; ?></td</tr></table> <?php
liomon41 at Yahoo! Answers Visit the source
Other answers
The above poster is correct, and as a side note .htaccess files are for the Apache webserver and don't relate to php code directly.
well if im correct you want a table to appear with various rows. you should be fetching the info from the database so what you would want to do is run a query to fetch the info and create a loop so the info can be displayed $query = "SELECT * FROM example"; $result = mysql_query($query) or die(mysql_error()); echo "<table>"; while($row = mysql_fetch_array($result)) { echo "<tr><td>'$row['column1'] '</td><td>'. $row['column2']'</tr>"; } echo "</table>";
<?php ... ?> is parsed by the "php" before anything else (almost) so that you can intermix it in a "normal" html page provided that the ext is .php and this extension is "enabled" to mean that it must be processed by the php interpreter someway. this means that codes like <html> <head><title><?php get_title(); ?></title> <meta http-equiv="Content-Type" content="text/html; charset=<?php get_charset(); ?>" /> </head> <body> <!-- <?php get_comment(); ?> --> </body></html> is perfectly working; in particular note that get_charset() is inside a "string" and get_comment() output is put into a html comment! so you can as well write things like <table> <tr> <td> <?php echo $name; ?> </td></tr></table> of course, for just one "name", otherwise you have to generate <td> from inside php, like <table><tr> <?php foreach($name_array as $name) { echo "<td>$name</td>"; } ?> </tr></table> so to say. .htaccess could be used to override the conf option that tells the server to understand only the tag <?php or rather also the shortest form <? but no harm if you write <?php instead of simply <? and live that option as it is
Be careful of Hippy's answer, lots of errors there (both HTML and PHP). He has the right idea, but he has more than one syntax error. .htaccess is for securing directories and subdirectories, it has nothing to do with PHP or HTML.
Related Q & A:
- How to parse .log file and insert into database in PHP?Best solution by unix.com
- How to upload a file to another server using cURL and PHP?Best solution by Stack Overflow
- how delete node in xml file using php?Best solution by Stack Overflow
- How convert .txt file to .Dat file in php?Best solution by Stack Overflow
- How to Rewrite URL in htaccess with php?Best solution by Stack Overflow
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.