PHP help

AdamSnow

Diamond Member
Nov 21, 2002
5,736
0
76
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??
 

AdamSnow

Diamond Member
Nov 21, 2002
5,736
0
76
Awesome... Thank you LoKe, you a a wealth of information.

I'll give this replacement code a try tomorrow...
 
Jun 4, 2005
19,723
1
0
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
 

AdamSnow

Diamond Member
Nov 21, 2002
5,736
0
76
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?
 
Jun 4, 2005
19,723
1
0
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'];
 

tfinch2

Lifer
Feb 3, 2004
22,114
1
0
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.
 

AdamSnow

Diamond Member
Nov 21, 2002
5,736
0
76
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!
 
Jun 4, 2005
19,723
1
0
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'];
 

AdamSnow

Diamond Member
Nov 21, 2002
5,736
0
76
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';
?>
 

tfinch2

Lifer
Feb 3, 2004
22,114
1
0
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.
 

tfinch2

Lifer
Feb 3, 2004
22,114
1
0
Originally posted by: LoKe
Try this.

For each returned row, it would just overwrite the old value previously in the variable.

While what he has is ugly, it's fine.
 
Jun 4, 2005
19,723
1
0
Originally posted by: tfinch2
Originally posted by: LoKe
Try this.

For each returned row, it would just overwrite the old value previously in the variable.

While what he has is ugly, it's fine.

With my code, it *should* create a new table for each set of returned results.
 

AdamSnow

Diamond Member
Nov 21, 2002
5,736
0
76
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.