|
-
Oct 14th, 2008, 04:21 AM
#1
Thread Starter
Frenzied Member
[RESOLVED] Displaying All Records
My code is only showing one record from the database how would i get it to show all the records from the database and not just one.?
PHP Code:
<?php
include("config.php");
mysql_connect("$host", "$username", "$password");
mysql_select_db($db) or die(mysql_error());
// Retrieve all the data from the "example" table
$result = mysql_query("SELECT * FROM ip")
or die(mysql_error());
// store the record of the "example" table into $row
$row = mysql_fetch_array( $result );
// Print out the contents of the entry
echo "IP: ".$row['ip'];
echo " Reason: ".$row['Reason'];
?>
come back and mark your original post as resoved if your problem is fixed
Jamie Garland
-
Oct 14th, 2008, 04:51 AM
#2
-
Oct 14th, 2008, 05:02 AM
#3
Thread Starter
Frenzied Member
Re: Displaying All Records
What would i need to do if there is no records how to i get it to display a message?
EDITED:::- I just added a new IP address and now it dosent show them on the display page but when i add another one it then displays the second ip address and not the first one and displays all the reson from there on.
http://prksoftware.co.uk/display.php
Last edited by Jamie_Garland; Oct 14th, 2008 at 05:15 AM.
come back and mark your original post as resoved if your problem is fixed
Jamie Garland
-
Oct 14th, 2008, 07:41 AM
#4
-
Oct 14th, 2008, 07:44 AM
#5
Thread Starter
Frenzied Member
Re: Displaying All Records
Config.php
PHP Code:
<?
// Please edit the variables below:
//Set the MySQL server address (usually localhost)
$host = "localhost";
//Enter the login name you wish to access your database with
$username = "web181-ipbanner";
//Enter the password to access the database
$password = "d82f1fc";
//Enter the database you wish to use
$db = "web181-ipbanner";
?>
display.php
PHP Code:
<?php
include("config.php");
mysql_connect("$host", "$username", "$password");
mysql_select_db($db) or die(mysql_error());
// Retrieve all the data from the "example" table
$result = mysql_query("SELECT * FROM ip")
or die(mysql_error());
// store the record of the "example" table into $row
$row = mysql_fetch_array( $result );
// Print out the contents of the entry
while($row = mysql_fetch_array( $result )) {
echo "<br>IP:<br> ".$row['ip'];
echo "<br>Reason:<br> ".$row['Reason']."<br /><hr>";
}
?>
come back and mark your original post as resoved if your problem is fixed
Jamie Garland
-
Oct 14th, 2008, 08:20 AM
#6
-
Oct 14th, 2008, 08:22 AM
#7
Thread Starter
Frenzied Member
Re: Displaying All Records
shall i remove this code.
PHP Code:
// store the record of the "example" table into $row
$row = mysql_fetch_array( $result );
// Print out the contents of the entry
come back and mark your original post as resoved if your problem is fixed
Jamie Garland
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|