•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 397,836 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,563 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 314 | Replies: 3
![]() |
•
•
Join Date: Aug 2006
Posts: 31
Reputation:
Rep Power: 3
Solved Threads: 0
I have a database called "App" and a table called appinfo.
I am able to connect to the database. It has only two entries since I am just trying to learn how to use php and sql together.
The first column in the appinfo table is called ID followed by 10 other columns. The ID is auto_increment.
So my question is how do i display one record's all of the columns in the database in a web page using php?
I am able to connect to the database. It has only two entries since I am just trying to learn how to use php and sql together.
The first column in the appinfo table is called ID followed by 10 other columns. The ID is auto_increment.
So my question is how do i display one record's all of the columns in the database in a web page using php?
--
DG
DG
•
•
Join Date: Jan 2008
Location: Bali - Indonesia
Posts: 61
Reputation:
Rep Power: 1
Solved Threads: 7
This is a simple way to do it :
hope it help
mysql_connect("yourhost","yourusername","yourpass");
mysql_select_db("yourdb");
$result = mysql_query(SELECT * FROM tablename LIMIT 1);
while($row = mysql_fetch_array($result)){
$var1 = $row["yourfield1"];
$var2 = $row["yourfield2"];
.
.
.
$var10 = $row["yourfield10"];
}
echo "$var1 <br> $var2 ..... <br> $var10"; I am a newbie to PHP but I am a VB programmer so it is not so strange. I had the same problem so here is my code displaying in a box on screen
This code if you place your info in the sections in bold will work .. enjoy :-)
php Syntax (Toggle Plain Text)
<?php $con = mysql_connect("connection","user","password"); if (!$con) { die('Could not connect: ' . mysql_error()); } print "Connected to MySQL<br>"; mysql_select_db("yourdatabase", $con); $result = mysql_query("SELECT * FROM yourtable ORDER BY yourfield"); // make box and name the fields in html echo "<table border='1'> <tr> <th>yourfield</th> <th>yourfield2</th> <th>yourfield3</th> </tr>"; // fill box with data while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['yourfield'] . "</td>"; echo "<td>" . $row['yourfield2'] . "</td>"; echo "<td>" . $row['yourfield2'] . "</td>"; echo "</tr>"; } echo "</table>"; print "Please feel free to useTrevor<br>"; mysql_close($con); ?>
This code if you place your info in the sections in bold will work .. enjoy :-)
Last edited by peter_budo : May 1st, 2008 at 12:22 pm. Reason: Keep It Organized - please use [code] tags
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
•
•
•
•
access advice ajax asp blog broadband code combo competition daniweb data data protection data transfer database developer development drive dropdownlist encryption europe forensic forensics hacker hard hardware help hitachi linux management studio 2005 microsoft mobile module msdn net news office php privacy reuse security software spam sql storage survey terabyte tv vista web wikipedia
- Help me with my myspace clone (PHP)
- Insert Selected data In MySQL (PHP)
- Open In New Window Php (PHP)
- Database class use (PHP)
Other Threads in the PHP Forum
- Previous Thread: mysql_fetch_array(): supplied argument is not a valid MySQL result resource
- Next Thread: how do i define dynamic array in php


Linear Mode