|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
php output to table
I am having difficulty trying to get a search result to display to a table. At the moment it lists the output all vertically ie.,
1. title1 1. genre1 1. format1 2. title2 2. genre2 2. format2 I really want it to display like: title1 | genre1 | format1 title2 | genre2 | format2 Here's the script (edited for security reasons): <html> <head> <title>Movies Search Results</title> </head> <body> <h1>Movies Search Results</h1> <? 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); @ $db = mysql_pconnect("*****","*****","*****"); if (!$db) { echo "Error: Could not connect to database. Please try again later."; exit; } mysql_select_db("*****"); $query = "select * from movies where ".$searchtype." like '%".$searchterm."%'"; $result = mysql_query($query); $num_results = mysql_num_rows($result); echo "<p>Number of entries found: ".$num_results."</p>"; for ($i=0; $i <$num_results; $i++) { $row = mysql_fetch_array($result); echo "<p><strong>".($i+1).". Title: "; echo htmlspecialchars( stripslashes($row["title"])); echo "<p><strong>".($i+1).". Genre: "; echo htmlspecialchars( stripslashes($row["genre"])); echo "<p><strong>".($i+1).". Format: "; echo htmlspecialchars( stripslashes($row["format"])); echo "<p><strong>".($i+1).". No of CD's: "; echo htmlspecialchars( stripslashes($row["cds"])); echo "</p>"; } ?> </body> </html> Any help would be appreciated !!! I am still trying to work it out myself, but if anybody can spot the problem please let me know. Cheers, Pha3dr0n |
|
#2
|
|||
|
|||
|
RE: php output to table
Check out this tutorial...
http://codewalkers.com/tutorials.php?show=15 |
|
#3
|
|||
|
|||
|
RE: php output to table
It's because you are using <p> tags not tags for a table. In your for() loop you want to have something like:
<? ... <tr><td>$array[1]</td><td>$array[2]</td><td>$array[3]</td></tr> ... ?> |
![]() |
| Viewing: Codewalkers Forums > PHP Related > PHP Coding > php output to table |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|