|
 |
|
 |
03-20-2007, 02:08 AM
|
#1 (permalink)
|
|
Salchester
Join Date: Jul 2005
Location: In a house
Posts: 230
|
PHP Display Data
Hi Everyone, hows it going?
I'm currently using the following code, inoder to create a table like structure on a page:
.cell
{
left: 0px;
top: 0px;
width: 100px;
height: 100px;
position: relative;
margin-left: 10px;
margin-bottom: 10px;
float: left;
}
how do i display all the first names and last names, stored in the database, inside different boxes, like a table? See below
Code:
<?php
$con = mysql_connect("localhost","peter","abc123");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("my_db", $con);
$result = mysql_query("SELECT * FROM person");
while($row = mysql_fetch_array($result))
{
echo $row['FirstName'] . " " . $row['LastName'];
echo "<br />";
}
mysql_close($con);
?>
| FIRSTNAME | LASTNAME |
| Brian | Tims |
| Stuart | Holmes |
Many Thanks,
__________________
Many Thanks, in advance!
Salchester.
The Future Is Here - Are You Ready?
|
|
|
03-20-2007, 06:39 AM
|
#2 (permalink)
|
|
Newbie
Join Date: Jun 2002
Location: Denmark
Posts: 1,695
|
Have you tried
PHP Code:
echo "<table> <tr><td>Firstname</td><td>Lastname</td></tr>"; while($row = mysql_fetch_array($result)) { echo "<tr><td>" . $row['FirstName'] . "</td><td> " . $row['LastName'] . "</td></tr>"; } echo "</table>";
??
And please dont post two threads about the same thing, edit your previus post to reflect the code, or add a reply to the thread containing your code.
|
|
|
03-20-2007, 07:20 AM
|
#3 (permalink)
|
|
Salchester
Join Date: Jul 2005
Location: In a house
Posts: 230
|
PHP Display Data
Redhead,
I'm trying to use CSS instead of tables, do you know how to display the data within the database inside separate divs, using the CSS declaration i gave you earlier?
For a diagram on what I'm trying to achieve, CLICK HERE
Sorry for duplicating posts!!!
Many Thanks,
__________________
Many Thanks, in advance!
Salchester.
The Future Is Here - Are You Ready?
|
|
|
03-20-2007, 12:34 PM
|
#4 (permalink)
|
|
Moderator
Join Date: May 2002
Location: us.ca
Posts: 4,471
|
i think this would work
HTML Code:
<div>
<div style="float:left;">firstname</div>
<div>lastname</div>
</div>
<div>
<div style="float:left;">firstname</div>
<div>lastname</div>
</div>
__________________
Mike
|
|
|
03-20-2007, 01:51 PM
|
#5 (permalink)
|
|
Salchester
Join Date: Jul 2005
Location: In a house
Posts: 230
|
PHP Display Data
SDE,
Using the code at the below link, how do I load all data from the database, but only display one piece of information i.e. Firstname or Lastname per div, in order to create a tabular structure, as shown in the diagram linked below.
Many Thanks,
__________________
Many Thanks, in advance!
Salchester.
The Future Is Here - Are You Ready?
|
|
|
03-20-2007, 03:03 PM
|
#6 (permalink)
|
|
Senior Contributor
Join Date: Mar 2005
Posts: 660
|
__________________

UT: Ultra-kill... God like!
|
|
|
03-20-2007, 04:44 PM
|
#7 (permalink)
|
|
Moderator
Join Date: May 2002
Location: us.ca
Posts: 4,471
|
that's cool, i didn't know about that.
Salch, u got a problem with your layout. if you stretch it out, it's going to to display more than 2 columns. example:
first | last | first|
last
however, if you wanted to use that HTML for your display output, your php would look something like this:
PHP Code:
while($row = mysql_fetch_array($result)) { echo "<div class=\"But\">". $row['FirstName'] . "</div><div class=\"But\">". $row['LastName'] . "</div>\n"; }
__________________
Mike
|
|
|
03-20-2007, 04:51 PM
|
#8 (permalink)
|
|
Moderator
Join Date: May 2002
Location: us.ca
Posts: 4,471
|
Quote:
Originally Posted by DJMaze
|
djm, renders nicely in FF, .. any way to be able to use that with IE?
Code:
<style>
.cell {
display: table-cell;
width: 150px;
border: 1px solid red;
padding: 10px;
margin: 0px;
}
.cell_left {
float:left;
}
</style>
<div>
<div class="cell">First</div>
<div class="cell">Last</div>
</div>
<div>
<div class="cell">First</div>
<div class="cell">Last</div>
</div>
<div>
<div class="cell">First</div>
<div class="cell">Last</div>
</div>
__________________
Mike
|
|
|
03-21-2007, 12:24 AM
|
#9 (permalink)
|
|
Salchester
Join Date: Jul 2005
Location: In a house
Posts: 230
|
Xampp - Apache
I'm trying to create a web-based application, using Xampp - Apache Server.
My creation along with the server will be run on a standalone pc.
Does anybody know if it is at all possible to lock people out of the HTDOCS folder, in order to avoid people from steeling my .html and .php code?
Many Thanks,
__________________
Many Thanks, in advance!
Salchester.
The Future Is Here - Are You Ready?
|
|
|
03-21-2007, 05:16 AM
|
#10 (permalink)
|
|
Senior Contributor
Join Date: Mar 2005
Posts: 660
|
Quote:
Originally Posted by sde
djm, renders nicely in FF, .. any way to be able to use that with IE?
|
As with many web-standards...... NO
But as always, there are people listed at google who do create workarounds
Mostly i just generate CSS thru php and:
PHP Code:
if (MSIE) { echo ' /* stupid IE never heard of standards */ .table { display: block; width: 200px; } .table-cell { display: block; width: 80px; float: left; } '; } else { /* you have a cool browser */ echo ' .table { display: table; } .table div { display: table-cell; } '; }
__________________

UT: Ultra-kill... God like!
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -8. The time now is 04:08 PM.
|
Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting
|
 |
|