Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more  

Go Back   Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more > Web Programming > Other Programming - Perl, C++, Java, ASP, .NET Development
User Name
Password

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 06-26-2005, 07:44 PM   #1 (permalink)
kayla
Member
 
Join Date: Jun 2005
Location: Tampa, Fla
Posts: 37
Default Listing mysql data using php

Hello,
I am very new to PHP but want to learn a little about it.

How can I list the contents of my mysql database in a column like fashion.
not this: Some Address Some City Some State Some Zip

I want the fields from my table displayed like this:
id_address
Some Address
Some City
Some State
Some Zip

id_address
Some Address
Some City
Some State
Some Zip

any help is appreciated for this novice, kay
kayla is offline   Reply With Quote
Sponsored Links
Old 06-26-2005, 09:07 PM   #2 (permalink)
xacto
Junior Member
 
Join Date: Jun 2005
Posts: 13
Default

Hi - Nice Forum WMF

`kayla` I think this might point you in the right direction.

PHP Code:
<html> 
<head> 
  <title>Results</title> 
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head> 
<body> 
<h1>Search Results</h1> 
<?php 
$database
="database_name"
mysql_connect ("localhost""username""password"); 
@
mysql_select_db($database) or die( "Unable to select database"); 
$query "select * from tablename"
$result mysql_query($query); 

  
$num_results mysql_num_rows($result); 

  echo 
"<p>Number matches found: ".$num_results."</p>"
  echo 
"<hr>"

  for (
$i=0$i <$num_results$i++) 
  { 
      
     
$row mysql_fetch_array($result); 
     echo 
"<p><strong># "
     echo 
stripslashes($row["contact_id"]); 
  echo 
"<p><strong>Name: "
     echo 
stripslashes($row["first_name"]); 
  echo 
"<p><strong>Category: "
     echo 
stripslashes($row["lastname"]); 
     echo 
"<p><strong>Comment: "
     echo 
stripslashes($row["comments"]); 
      echo 
"<hr>"
     echo 
"</p>"
  } 

?> 
</body> 
</html>


cheers
xacto is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On

Points Per Thread View: 1.00
Points Per Thread: 11.00
Points Per Reply: 5.00


Similar Threads
Thread Thread Starter Forum Replies Last Post
Display mysql table fields and data goldfish PHP Development 6 05-14-2008 03:49 AM
PHP form for entering data to MySQL database vvaldir PHP Development 31 08-26-2006 11:44 AM


» Sponsors

» Links

» Affiliates
Web Hosting
Marketing Find
Merchant Select
SiteMap Builder
Host Compare
Dedicated Servers

» Links

» Sports Network
Paintball Forum
Football Forum
Hockey Forum
Golf Forum
Boxing Forum
Lacrosse Forum
Baseball Forum
SnowBoarding Forum
Soccer Forum
MMA Forum


All times are GMT -4. The time now is 05:51 PM.



LinkBacks Enabled by vBSEO 3.0.0 RC8
Webmaster Forums