PHP Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPHP Coding

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
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  
Old September 2nd, 2002, 11:40 AM
pha3dr0n pha3dr0n is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 12 pha3dr0n User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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


Reply With Quote
  #2  
Old September 2nd, 2002, 03:06 PM
Matt Matt is offline
Moderator
Codewalkers Specialist (4000 - 4499 posts)
 
Join Date: Apr 2007
Location: Florida
Posts: 4,158 Matt User rank is Private First Class (20 - 50 Reputation Level)Matt User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 h 10 m 20 sec
Reputation Power: 6
RE: php output to table

Check out this tutorial...

http://codewalkers.com/tutorials.php?show=15

Reply With Quote
  #3  
Old September 2nd, 2002, 08:58 PM
Nimco Nimco is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 132 Nimco User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via AIM to Nimco
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>
...
?>

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > php output to table


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway