This is a discussion on "php to html help please" within the PHP Forum section. This forum, and the thread "php to html help please are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
php to html help please
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
php to html help please
I have a results page to a search but it is using the echo function to print it to screen.
I cannot seem to be able to format it so that they come up as a table. How can I change the code so that I can have these results in an HTML table such as those on record charts pages. It is the echo statements at the bottom that I am having problems converting. If anyone can amend this code for me it will be very much appreciated. This is the code for the search results page: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Search Results</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <script language="JavaScript" type="text/JavaScript"> <!-- function MM_reloadPage(init) { //reloads the window if Nav4 resized if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) { document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }} else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload(); } MM_reloadPage(true); //--> </script> <link rel="stylesheet" href="books.css"> </head> <body class="body"> <table width="95%" border="0" align="center" cellpadding="3" cellspacing="0"> <tr> <td width="11%" rowspan="2">[img]logo.gif[/img]</td> <td height="82" colspan="3"> <div align="center">[img]ptBanner.gif[/img]</div></td> </tr> </table> <table width="237"> <tr align="center" class="years-ago"><td>Pageturners Search Results</td></tr></table> <?php //create short variable names $searchtype=$HTTP_POST_VARS['searchtype']; $searchterm=$HTTP_POST_VARS['searchterm']; $searchterm= trim($searchterm); if (!$searchtype || !$searchterm) { echo 'You have not entered search details. Please go back and try again.'; exit; } $searchtype = addslashes($searchtype); $searchterm = addslashes($searchterm); @ $DbConn = mysql_connect("localhost","root","poppet"); if (!$DbConn) { echo "Error, Could not connect to the system database. Sorry..."; exit; } mysql_select_db('charts50'); $query = "select * from uk where ".$searchtype." like '%".$searchterm."%'"; $result = mysql_query($query); $num_results = mysql_num_rows($result); echo ' Number of records found: '.$num_results.'</p>'; for ($i=0; $i <$num_results; $i++) { $row = mysql_fetch_array($result); echo ' [b]'.($i+1).' TW: '; echo (stripslashes($row['TW'])); echo '[b] LW: '; echo stripslashes($row['LW']); echo ' Wks: '; echo stripslashes($row['Wks']); echo ' Title: '; echo stripslashes($row['Title']); echo ' Artist: '; echo stripslashes($row['Artist']); echo ' Date: '; echo stripslashes($row['Date']); } ?> </body> </html> |
|
|
|
|||
|
Just draw up a table in standard HTML and then place the code around the PHP you have.
You can always end segments of PHP and have some HTML, then have another segment of PHP for the table content. |
|
|||
|
<blockquote id="quote"><font size="1" face="geneva, verdana, arial" id="quote">quote:<hr height="1" noshade id="quote">Originally posted by Sirkent
Just draw up a table in standard HTML and then place the code around the PHP you have. You can always end segments of PHP and have some HTML, then have another segment of PHP for the table content. <hr height="1" noshade id="quote"></blockquote id="quote"></font id="quote"> Sounds easier said than done. I may sound a bit thick but being a newbie to PHP I don't quite understand how this is done. Could you just give me one example please. |
|
|||
|
Well you can see that the < ? php tag starts halfway through the HTML and ends just before the end ? >
You should know basic HTML before you tackle any web language. So draw up a table in HTML. This part:
First you will want your table header, so TW, LW, Weeks, etc in full (this should be before the for loop altogether). Then you will want to place a new row at the beginning of the loop, then loop through each piece of information placing it in a seperate cell until the end of your loop when you end the row. Therefore, each time the loop runs once, it spits out a row with your values. |
![]() |
| Tags |
| php, html, help |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| HTML, css and php | gecko | Web Page Design | 4 | Apr 17th, 2008 07:44 |
| Can I do this with html or anything else??? | Petey_ | Web Page Design | 2 | May 31st, 2006 21:04 |
| PHP within HTML | stickywicket | PHP Forum | 0 | Dec 6th, 2005 19:05 |
| Html | leonheart | Introduce Yourself | 3 | Aug 19th, 2005 21:55 |