php mysql table view not showing all fields.. Not sure why. :(

So I have 4 different files, dealersubmission.html which is the form page, create_table.php which creates the table on the database, insert.php which puts the information from the form into the table, and view.php which views the table. My problem is that I can’t for some reason, see past the first two fields when I go to look at it. It’s been racking at my brain for a few days now… Originally just the first field wouldn’t show, then I had someone look at it and got the first two fields showing, which at the time was all we had in it. But now that I added the rest of them, they aren’t showing up. x.x But uh… Here is the 3 php files:

create_table.php
[php]<?php
include “data.php”;

$query = “DROP DATABASE IF EXISTS machina_con”;
$result = mysql_query($query) or die(mysql_error());

$query = “CREATE DATABASE machina_con”;
$result = mysql_query($query) or die(mysql_error());

mysql_select_db(“machina_con”) or die(mysql_error());

$query = “CREATE TABLE Dreg
(
companyname TEXT,
contactname TEXT,
contactemail TEXT,
contactphone TEXT,
companyaddress TEXT,
companywebsite TEXT,
DregID INT NOT NULL PRIMARY KEY AUTO_INCREMENT
)”;

$result = mysql_query($query) or die(mysql_error());

mysql_close();

echo “Done”;
?>

[/php]

insert.php
[php]<?php

include “data.php”;

$companyname = $_POST[‘companyname’];
$contactname = $_POST[‘contactname’];
$contactemail = $_Post[‘contactemail’];
$contactphone = $_Post[‘contactphone’];
$companyaddress = $_Post[‘companyaddress’];
$companywebsite = $_Post[‘companywebsite’];

mysql_query("INSERT INTO Dreg
(companyname, contactname, contactemail, contactphone, companyaddress, companywebsite, DregID) VALUES(’$companyname’, ‘$contactname’, ‘$contactemail’, ‘$contactphone’, ‘$companyaddress’, ‘$companywebsite’, ‘’ ) ")
or die(mysql_error());

echo “1 record added”;

mysql_close()

?>

[/php]

view.php
[php]<?php

include “data.php”;

$result = mysql_query(‘SELECT * FROM Dreg’)
or die(mysql_error());

while($row = mysql_fetch_array( $result )) {

$company = $row[‘companyname’];
$contact = $row[‘contactname’];
$contactemail = $row[‘contactemail’];
$contactphone = $row[‘contactphone’];
$companyaddress = $row[‘companyaddress’];
$companywebsite = $row[‘companywebsite’];

echo "$contact, from $company
";

echo “Contact: $contact
Company: $company
E-mail: $contactemail
Phone: $contactphone
Address: $companyaddress
Website: $companywebsite”;

echo "


















Company Name Contact Name Contact E-mail Contact Phone Company Address Company Website
$company $contact $contactemail $contactphone $companyaddress $companywebsite
";
}

mysql_close();
?>
[/php]

Thanks for any help you can give me!

My problem is that I can't for some reason, see past the first two fields when I go to look at it.

Do you mean the fields on the HTML page? Could you link to an example of the script in action, or post a screenshot of what you do see? As I’m not 100% sure I understand the issue…

well here is two things to try, without any explanation of an error, I am just trying to see what I could do to help first change insert.php to:
[php]

<?php include "data.php"; $companyname = "{$_POST['companyname']}"; $contactname = "{$_POST['contactname']}"; $contactemail = "{$_Post['contactemail']}"; $contactphone = "{$_Post['contactphone']}"; $companyaddress = "{$_Post['companyaddress']}"; $companywebsite = "{$_Post['companywebsite']}"; mysql_query("INSERT INTO `Dreg` ( `companyname` , `contactname` , `contactemail` , `contactphone` , `companyaddress` , `companywebsite` , `DregID` )VALUES ('$companyname', '$contactname', '$contactemail', '$contactphone', '$companyaddress', '$companywebsite', '' ) ") or die(mysql_error()); echo "1 record added"; mysql_close() ?>

[/php]

Just minor changes there, next change view.php to
[php]

<?php include "data.php"; $result = mysql_query('SELECT * FROM Dreg') or die(mysql_error()); while($row = mysql_fetch_assoc( $result )) { $company = "{$row['companyname']}"; $contact = "{$row['contactname']}"; $contactemail = "{$row['contactemail']}"; $contactphone = "{$row['contactphone']}"; $companyaddress = "{$row['companyaddress']}"; $companywebsite = "{$row['companywebsite']}"; echo "$contact, from $company
"; echo "Contact: $contact
Company: $company
E-mail: $contactemail
Phone: $contactphone
Address: $companyaddress
Website: $companywebsite"; echo "
Company Name Contact Name Contact E-mail Contact Phone Company Address Company Website
$company $contact $contactemail $contactphone $companyaddress $companywebsite
"; }mysql_close(); ?>

[/php]
again just some minor changes there, I hope this helps!

Sponsor our Newsletter | Privacy Policy | Terms of Service