Jump to content

HTMLTable in php page not working properly!


erok

Recommended Posts

Hi peoplei have a customerlist in a table inside php page.Table starts about twenty line down form the top of the page. I do not know why there are about twenty line white space from the top before table starts. When i insert new row to the table it push the table one more line down.Which means one more line white space from the top before the table.When i insert another new row, one more white space line from the top before the table and so on.I looked the CSS and HTML i do not see any problem. Is it possible problem comes from the php? I am working with xampp and phpmy admin in windows 7. i use php 5.3 Another thing, my customerlist is case sensitive. How can i make it case insensitive?I do not want same record twice in the table.Any direction appreciatedErok

Link to comment
Share on other sites

make sure everything is close properly, double check the loops, echos, and the <table><tr><td> are all closed if anything post your codes

Link to comment
Share on other sites

Here is the code for this program; <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "htpp://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head> <title>retrieve data from database</title> <META name="ROBOTS" content="NOINDEX, NOFOLLOW"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="author" content="Erol " /> <link rel="stylesheet" type="text/css" href="layyerel.css" /></head><body><?phperror_reporting(E_ALL);ini_set('display_errors', true);ini_set('html_errors', true);//connect to database server$con = mysql_connect("localhost", "root", "");if (!$con) { die('could not connect: ' .mysql_error()); }// select databasemysql_select_db("theboatcare", $con) or die("Could not find DB");$customers= "SELECT * FROM customers" ;$recordset= mysql_query($customers) ;echo "<h4>The BoatCare Customer List</h4>";echo "<table border='2' padding='3' cellspacing='3'>; <tr> <th>First Name</th> <th>Last Name</th> <th>Phone Number</th> </tr>";while( $row = mysql_fetch_array($recordset)) { echo "<tr>"; echo "<td>" . $row['firstname'] . "</td>" . "<td>" . $row['lastname'] . "</td>" . "<td>" . $row['phone'] . "</td>" . "<br />" ; echo "</tr>"; } echo "</table>";//close the database connectionmysql_close($con);?></body></html>

Link to comment
Share on other sites

Thannkk you very much justsomeguy, Problem solved, exactly as you said. Could you help me about;I wrote a code if a record is already exist program refuse to insert the same record again and produce a warning However,Program does not recognize if it is the same record when i insert the same values with different case letters e.g. uppercase and lowercase.i do not want to duplicate the same record. How can i make this program case insensitive? Another thingWhen i insert a new record it does not go to end of the list.It inserts new record in the list randomly or i am guessing, in previously deleted row place. How can i make it inserting last record goes all the way to end of the list?Thanks anyway for your help so far.erok

Link to comment
Share on other sites

Several character sets are case-insensitive by default, when you're setting up a table in phpMyAdmin those character sets have a ci in them, like unicode_ci. Otherwise, you can use the string functions to convert to a certain case, e.g.: $sql = 'SELECT * FROM table WHERE LOWER(field_name) = \'' . strtolower($value) . '\''; http://dev.mysql.com/doc/refman/5.0/en/string-functions.html

When i insert a new record it does not go to end of the list.It inserts new record in the list randomly or i am guessing, in previously deleted row place. How can i make it inserting last record goes all the way to end of the list?
That probably depends how you're sorting the data in the select query. You should use an autoincrement ID field and order your queries by that field to have them returned in the order in which they were added.
Link to comment
Share on other sites

Thanks justsomeguy, Program case-insensitive now. it does not duplicate the same record just because using different case characters.I replaced utf8_bin to utf8_unicode_ci. I added ORDER BY id to select query. Since then last record goes to end of the list.Erok

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...