|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this 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
|
||||
|
||||
|
How do I get info from my database onto a web page the way I want it?
I have been trying to figure this out but I haven't had any success. I am trying to figure out how to get the information from a query to appear on a web page just the way I want it. I know how to call the information up by using something like this:
<HTML> <?php $db = mysql_connect("localhost", "user", "pass"); mysql_select_db("name",$db); $result = mysql_query("SELECT * FROM table WHERE id=$id",$db); $myrow = mysql_fetch_array($result); echo "field 1: ".$myrow["fieldone"]; echo "<br>field 2: ".$myrow["fieldtwo"]; echo "<br>field 3: ".$myrow["fieldthree"]; echo "<br>field 4: ".$myrow["fieldfour"]; echo "<br>field 5: ".$myrow["fieldfive"]; ?> </HTML> But what if I want this information to come up in a formatted page with columns and rows? Something like this: <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body bgcolor="#FFFFFF" text="#000000"> <table width="90%" border="0" cellpadding="2"> <tr> <td>fieldone</td> <td>fieldtwo</td> </tr> <tr> <td>fieldthree</td> <td>fieldfour</td> </tr> <tr> <td>fieldfive</td> <td>blah blah blah</td> </tr> </table> </body> </html> I know this has got to be really really easy, but I can't figure it out. Last edited by strangepup : May 29th, 2002 at 02:21 PM. |
|
#2
|
|||
|
|||
|
yes, it is really easy
you have just overlooked the problem. <?php $db = mysql_connect("localhost", "user", "pass"); mysql_select_db("name",$db); $result = mysql_query("SELECT * FROM table WHERE id=$id",$db); $myrow = mysql_fetch_array($result); ?> <body bgcolor="#FFFFFF" text="#000000"> <table width="90%" border="0" cellpadding="2"> <tr> <td><?php $myrow["fieldone"]; ?></td> <td><?php $myrow["fieldtwo"]; ?></td> </tr> <tr> <td><?php $myrow["fieldthree"]; ?></td> <td><?php $myrow["fieldfour"]; ?></td> </tr> <tr> <td><?php $myrow["fieldfive"]; ?></td> <td><?php $myrow["fieldsix"]; ?></td> </tr> </table> </body> if you have short tags on you can change it to this <? $myrow["fieldone"] ?> hope that helps ya |
|
#3
|
||||
|
||||
|
Thanks Ben, you rule!!!
|
|
#4
|
|||
|
|||
|
no probs, try using the while statment as well, s
like while($myrow = mysql_fetch_array($result) { } that way it ca save you re-writing scipt |
![]() |
| Viewing: Dev Articles Community Forums > Databases > Database Development > How do I get info from my database onto a web page the way I want it? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|