• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

PHP help

AdamSnow

Diamond Member
I'm trying to make a form, that will pull a bunch of information in from a database... I can do it no problem with ECHO's, but of course it's not very pretty... I'd like to dump a bunch of stuff into a table, and it doesn't seem to work... wondering if anyone can help?

Here's my code:



I get an error at line " <table border="0" width="100%" cellpadding="0" cellspacing="0"> " so I know it doesn't like that code... but I'm not sure where to go from here... Any suggestions??
 
Originally posted by: troytime
is there a reason for all the missing semicolons?

Semi-colons aren't necessary when dealing with one-line strings. Sure, you could use them, but they're just a waste of space. =D
 
Hey guys... Using the code that LoKe provided, it will now make the correct number of cells and everything, but no data is actually published inside of them.

Any suggestions?
 
Was it providing the information before the modification? I'll look over the code.

EDIT: As TFinch2 said, there needs to be data assigned to the variables. Ex:

$ID = $row['ID'];
$ProjectName = $row['ProjectName'];
$Contact = $row['Contact'];
$StartDate = $row['StarDate'];
$EndDate = $row['EndDate'];
$Priority = $row['Priority'];
 
Do the variables have any data assigned to them?

Before you echo one, manually assign it some string to test it. If it echos the string, that means the variables need to have the POSTed data assigned to them.
 
Yes, it provides the information before the modification... only it's very ugly, and takes up 8 lines to post the data... that's why I want to throw it into a table... 🙂

Thatnks for looking over the code!
 
Check out your query and make sure you're calling the right info. I tested it using manually set variables and it works just fine.

EDIT: Also, could you please show us the portion of your code where you set these variables? They should look something like : $ID = $row['ID'];
 
It's not coming from a POST or anything, so I didn't think I needed to assign the data...

Here's the code for the working version right now, but as you can tell - it's ugly.

<?php
include 'config2.php';
include 'opendb.php';
$query = "SELECT ID, ProjectName, Contact, Description, StartDate, EndDate, Notes, Priority, Completed FROM Projects WHERE Completed ='No' ";
$result = mysql_query($query);
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
echo "<B>ID : </B> {$row['ID']}<br>" .
"<B>Project Name : </B> {$row['ProjectName']}" .
"<B>Contact :</B> {$row['Contact']} <br>" .
"<B>Description :</B> {$row['Description']} <br>" .
"<B>Start Date :</B> {$row['StartDate']}" .
"<B>End Date : </B>{$row['EndDate']} <br>" .
"<B>Notes :</B> {$row['Notes']}<br>" .
"<B>Priority :</B> {$row['Priority']}<br><br>";
}

include 'closedb.php';
?>
 
You're echoing the data returned from the query, but you're not assigning it to any variable.

In the code posted above, $ProjectName has never been assigned a value for example, so it's empty.
 
Seems to work... pulls in tables, show's data... but it's messy as hell... 🙂

I've just gotta do some formatting and it looks like I'll be set!

You guys rock! Thank you so much.
 
Back
Top