468,249 Members | 1,494 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,249 developers. It's quick & easy.

Desperate help needed on tables in .php

DESPERATE doesn't begin to describe it.

Can someone PLEASE tell me what is WRONG with this code?

Now..a bit of background. It is a search results page for
http://www.azsoma.info/directory.htm. (use Scottsdale for the city)

If you go look, you see that the search results post (I do have my
table borders up for debugging) but it doesn't line up with the table
above it...the whole scroll background doesn't show up and I cannot get
my results to have a space between them. And on top of it...they want
an inline frame! I haven't even attempted that...at all....

Please...can someone help me. Hell, I'll pay someone if I have to...be
glad to...but this page needs to be done for the client....

Warning...long coding....

Thank you in advance....please, if someone could/would help me....

Code:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
<title>Directory Search Results</title>
</head>

<body bgcolor="#000000">
<div align="center">

<table width="800" border="1" cellpadding="0" cellspacing="0"
height="100%">
<table width ="800" border="1" cellpadding="0" cellspacing="0"
height="15%>

<tr>
<td width="4"></td><td valign="top" align="center" height="19%">
<img border="0" src="images/header3.gif" width="800"
height="150"></td></tr></table>

<table width ="800" border="1" cellpadding="0" cellspacing="0"
height="10%">
<tr>
<td width ="800" height="19" bgcolor="e1d7a4" valign="top"
align="center">

<p style="margin-left: 25"><br>
<font face="Rockwell" size="2" color="#990000"> <font color="FF7256">
<a href="/index.htm"><font color="#990000">Home</font></a></font><font
color="#990000">&nbsp;&nbsp;&nbsp;&nbsp;
</font> <font color="FF7256">
<a href="application.htm"><font color="#990000">Member
Application</font></a><font color="#990000">&nbsp;&nbsp;&nbsp;&nbsp;
</font>
<a href="/membership.htm"><font color="#990000">Member
Benefits/Products</font></a><font
color="#990000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</font>
<a href="/directory.htm"><font color="#990000">Member
Directory</font></a><font
color="#990000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</font>
<a href="/news.htm"><font
color="#990000">Announcements/News/Links</font></a></font></font></p></td></tr></table>

<table width = "800" border ="1" cellpadding="0" cellspacing="0"
align="center" background="images/scroll.jpg" length="800">
<form method="post" action="http://azsoma.info/results.php">


<!-- <table width="800" border="1" cellpadding="1"
cellspacing="0" align="center" background="images/qi-gong2_16.jpg"
height="100%"> -->

<!-- <tr>

<!-- <td width="60" valign="top"><b>id</b></td> -->
<!-- <td width="20%"><font size="3" color="990000">Full
Name</font></td> -->
<!-- <td width="30%"><font size="3"
color="990000">Address</font></td> -->
<!-- <td width="10%"><font size="3"
color="990000">City</font></td> -->
<!-- <td width="10%"><font size="3"
color="990000">Zip</font></td> -->
<!-- <td width="10%"><font size="3"
color="990000">Phone</font></td> -->
<!-- <td width="20%"><font size="3" color="990000">Website
Address</font></td> -->
<!-- </tr> -->

<tr>


php:
<?php
//print_r($_POST);
//echo "<br>\n";

$hostname = "***DON'T SHOW***"; // The server.
$username = "***DON'T SHOW***"; // The username you created for this
database.
$password = "***DON'T SHOW***"; // The password you created for the
username.
$usertable = "***DON'T SHOW***"; // The name of the table you made.
$dbName = "***DON'T SHOW***"; // This is the name of the database you
made.

MYSQL_CONNECT($hostname, $username, $password) OR DIE("DB connection
unavailable");
@mysql_select_db( "$dbName") or die( "Unable to select database");

//error message (not found message)begins
// $XX = "No Record Found, to search again please close this window";

/*+-------------------------------------------------------------------------------------+

| Query Details Begin:
|

+-------------------------------------------------------------------------------------+

| Since I don't know if phpForms has a built in search function and I
don't have time |
| to try to decipher how they are storing/retrieving information from
the tables, |
| this is the long way around it but it should work.
|

+-------------------------------------------------------------------------------------+

| May 2006 - AJM re-edited by RJP
|

+-------------------------------------------------------------------------------------+*/
/*+-------------------------------------------------------------------------------------+

| First we get all distinct records that have the matching criteria
from the search |
| page (directory.htm)
|

+-------------------------------------------------------------------------------------+

| Determine which fields they have used: Name, City, Zip - and build
the WHERE clause |

+-------------------------------------------------------------------------------------+*/

$sql = "SELECT DISTINCT sub_rec_id "
." FROM pf_submissions "
." WHERE ";

if($_POST['Name']>"")
$sql .= " (sub_fld_name LIKE '%name%' AND sub_fld_value LIKE '%".
$_POST['Name']. "%') AND ";

if($_POST['City']>"")
$sql .= " (sub_fld_name LIKE '%city%' AND sub_fld_value LIKE '%".
$_POST['City']. "%') AND ";

if($_POST['Zip']>"")
$sql .= " (sub_fld_name LIKE '%zip%' AND sub_fld_value LIKE '%".
$_POST['Zip']. "%') AND ";

$sql .= " 1=1 "
." ORDER BY sub_rec_id ASC";

//echo "sql=".$sql."<br>\n";
$qry = mysql_query($sql);

/*+-------------------------------------------------------------------------------------+

| Now, if there are any records, we'll step through getting the name
first. |

+-------------------------------------------------------------------------------------+*/

while($row=@mysql_fetch_array($qry))
{
$sqlName = "SELECT sub_fld_value "
." FROM pf_submissions "
." WHERE sub_rec_id = '" .$row["sub_rec_id"]. "' "
." AND sub_fld_name = 'Full Name'";
//echo "sqlName=".$sqlName."<br>\n";

$qryName = mysql_query($sqlName);
$rowName = @mysql_fetch_row($qryName);
//print_r($rowName);
//print("<br>\n");

print(" <tr height='20'><td valign='top'><p
style='margin-left:150'><font
size='2'>".$rowName[0]."</font></td></tr><br>\n");
/*+---------------------------------------------------------------------------------+

| Now, if there are any records, we'll step through getting the
office address. |

+-----------------------------------------------------------------------------------+*/

$sqlAddress = "SELECT sub_fld_value "
." FROM pf_submissions "
." WHERE sub_rec_id = '" .$row["sub_rec_id"]. "' "
." AND sub_fld_name = 'Office Address'";
// echo "sqlAddress=".$sqlAddress."<br>\n";

$qryAddress = mysql_query($sqlAddress);
$rowAddress = @mysql_fetch_row($qryAddress);
print(" <tr height='20' valign='top'><td valign='top'><p
style='margin-left:150'><font
size='2'>".$rowAddress[0]."</font></td></tr><br>\n");

/*+-----------------------------------------------------------------------------------+

| Now, if there are any records, For now we get the Office City.
|

+-------------------------------------------------------------------------------------+*/

$sqlCity = "SELECT sub_fld_value "
." FROM pf_submissions "
." WHERE sub_rec_id = '" .$row["sub_rec_id"]. "' "
." AND sub_fld_name = 'Office City'";
//echo "sqlCity=".$sqlCity."<br>\n";

$qryCity = mysql_query($sqlCity);
$rowCity = @mysql_fetch_row($qryCity);
print(" <tr height='20'><td valign='top'><p
style='margin-left:150'><font
size='2'>".$rowCity[0]."</font></td></tr><br>\n");
/*+-------------------------------------------------------------------------------------+

| Now, if there are any records, we'll step through getting the
Office state. |
| RJP 05/28/06
|

+-------------------------------------------------------------------------------------+*/

$sqlState = "SELECT sub_fld_value "
." FROM pf_submissions "
." WHERE sub_rec_id = '" .$row["sub_rec_id"]. "' "
." AND sub_fld_name = 'Office State'";
//echo "sqlState=".$sqlState."<br>\n";

$qryState = mysql_query($sqlState);
$rowState = @mysql_fetch_row($qryState);
print(" <tr height='20'><td valign'top'><p
style='margin-left:150'><font
size='2'>".$rowState[0]."</font></td></tr><br>\n");

/*+-------------------------------------------------------------------------------------+

| Now, if there are any records, we'll step through getting the
Office zip. |
| RJP 05/17/06
|

+-------------------------------------------------------------------------------------+*/

$sqlZip = "SELECT sub_fld_value "
." FROM pf_submissions "
." WHERE sub_rec_id = '" .$row["sub_rec_id"]. "' "
." AND sub_fld_name = 'Office Zip'";
//echo "sqlZip=".$sqlZip."<br>\n";

$qryZip = mysql_query($sqlZip);
$rowZip = @mysql_fetch_row($qryZip);
print(" <tr height='20'><td valign'top'><p
style='margin-left:150'><font
size='2'>".$rowZip[0]."</font></td></tr><br>\n");
/*+------------------------------------------------------------------------------------+

| Now, if there are any records, we'll step through getting the
Office Phone Number. |
| RJP 05/17/06
|

+-------------------------------------------------------------------------------------+*/

$sqlPhone = "SELECT sub_fld_value "
." FROM pf_submissions "
." WHERE sub_rec_id = '" .$row["sub_rec_id"]. "' "
." AND sub_fld_name = 'Office Phone'";
//echo "sqlPhone=".$sqlPhone."<br>\n";

$qryPhone = mysql_query($sqlPhone);
$rowPhone = @mysql_fetch_row($qryPhone);
print(" <tr height='20'><td valign='top'><p
style='margin-left:150'><font
size='2'>".$rowPhone[0]."</font></td></tr><br>\n");
/*+------------------------------------------------------------------------------------+

| Now, if there are any records, we'll step through getting the
Website. RJP 05/17/06 |

+-------------------------------------------------------------------------------------+*/

$sqlWeb = "SELECT sub_fld_value "
." FROM pf_submissions "
." WHERE sub_rec_id = '" .$row["sub_rec_id"]. "' "
." AND sub_fld_name = 'Website Address'";
//echo "sqlWeb=".$sqlWeb."<br>\n";

$qryWeb = mysql_query($sqlWeb);
$rowWeb = @mysql_fetch_row($qryWeb);
print(" <tr height='20'><td valign='top'><p
style='margin-left:150'><font
size='2'>".$rowWeb[0]."</font></td></tr><br>\n");


print(" </tr>\n");
}

//below this is the function for no record!!
if (!$variable1)
{
print ("$XX");
// echo " </tr>\n";
}
//end

?>
</table>

</table>

</div>
</body>

</html>

May 29 '06 #1
7 1411


La********@gmail.com wrote:
DESPERATE doesn't begin to describe it.

Can someone PLEASE tell me what is WRONG with this code?


Without even going into the php, IMHO you need to tidy up the HTML
that the code generates:

<a href="/directory.htm"><font color="#990000">Member
Directory</font></a><font color="#990000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</font>

5 non breaking spaces in a shade of red? Surely, there is better
ways to space things. I'd also suggest using some basic CSS for the
table layouts instead of trying to give all cells own parameters.

Lastly, try some html table generators. Yours is broken, eg:

<tr height='20'><td valign'top'><p style='margin-left:150'><font
size='2'>AZ</font></td></tr><br>

<tr height='20'><td valign'top'><p style='margin-left:150'><font
size='2'>85259</font></td></tr><br>

At least '=' is missing here.

/Marcin
May 29 '06 #2
Message-ID: <11**********************@i40g2000cwc.googlegroups .com> from
La********@gmail.com contained the following:
Warning...long coding....


Gulp! That is one messy bit of code. Deprecated code, nested tables,
no CSS. Ugh!

Your database queries (which I'm sure can be optimised) are outputting
something like this

print(" <tr height='20'><td valign='top'><p
style='margin-left:150'><font
size='2'>".$rowName[0]."</font></td></tr><br>\n");

For starters, that's a single column. It will never line up with a multi
column header

Frankly I wouldn't even try to start fixing this. It needs to be
rewritten from scratch.
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
May 29 '06 #3
La********@gmail.com wrote:
DESPERATE doesn't begin to describe it.

Can someone PLEASE tell me what is WRONG with this code?

Now..a bit of background. It is a search results page for
http://www.azsoma.info/directory.htm. (use Scottsdale for the city)

If you go look, you see that the search results post (I do have my
table borders up for debugging) but it doesn't line up with the table
above it...the whole scroll background doesn't show up and I cannot get
my results to have a space between them. And on top of it...they want
an inline frame! I haven't even attempted that...at all....

Please...can someone help me. Hell, I'll pay someone if I have to...be
glad to...but this page needs to be done for the client....

Warning...long coding....

Thank you in advance....please, if someone could/would help me....


<snipped code>

Hi,

Please try to be nice to this group.
Instead of expecting from the readers to wrestle through many many unrelated
lines of (broken) HTML, you might consider to strip it down to your
coreproblem, and post that.

A possible healthy side effect: When you strip the code down the problem,
you often see what is wrong yourself because you are not subtracted by
noise.)

Of course, if you are lucky a friendly soul will answer you anyway.
Your chances to get an answer are just better if you keep your question to
the point.

Regards,
Erwin Moller
May 29 '06 #4
La********@gmail.com wrote:
DESPERATE doesn't begin to describe it.

Can someone PLEASE tell me what is WRONG with this code?

Now..a bit of background. It is a search results page for
http://www.azsoma.info/directory.htm. (use Scottsdale for the city)

If you go look, you see that the search results post (I do have my
table borders up for debugging) but it doesn't line up with the table
above it...the whole scroll background doesn't show up and I cannot get
my results to have a space between them. And on top of it...they want
an inline frame! I haven't even attempted that...at all....

Please...can someone help me. Hell, I'll pay someone if I have to...be
glad to...but this page needs to be done for the client....

Warning...long coding....

Thank you in advance....please, if someone could/would help me....

Wow! a lot of things could be improved on this page.

1. Use a stylesheet.

2. Dump the boxed comments especially when they state the obvious. (i.e.
Now, if there are any records, we'll set through getting the xxx.)

3. Since the only difference in a bunch of these is the xxx value, make
it a function.

function showInTable($sub_fld_name) {
$sql = "select sub_fld_value "
."from pf_submissions "
."where sub_rec_id = '{$row['sub_rec_id']' "
."and sub_fld_name = '$sub_fld_name' ";

$result = mysql_query($sql);
while( $row = @mysql_fetch_row($result) {
?>
<tr height="20">
<td valign="top">
<p style="margin-left:150"> // stylesheets would be better here
<font size="2">
<?php echo $row[0];?>
</font>
</p>
</td>
</tr>
<?php
}
$mysql_free_result($result);
}

This reduces your inner loop to something like:
foreach( array('Full Name', 'Office Address', 'Office City', ...) as
$field_name ) {
showInTable($field_name);
}

4. Remove the silly 1=1 test use a boolean flag to know whether this is
the first entry (i.e. the where)

5. You don't close your <form>

6. Since both your outer table and inner table have width 800, I don't
understand what you want the outer table to do.

7. $variable1 is never set

8. The <br> at the end of each table row will not cause double spacing.
Either set double spacing up in the style sheet (preferred) or alter the
showInTable function to emit an empty row (<tr><td>&nbsp;</td></tr>)
after each populated row.

That's probably enough to get you started.

-david-
May 29 '06 #5
Okay, I want to thank everyone who answered me. For the record, I
didn't actually write the .php code for that search results page. I'm
just trying to get the .html part to work, with the .php. The guy who
wrote it... I told him the tables didn't line up right..he said it was
in the .html code...and I've been looking for DAYS now! I felt it was
in the .php code...somewhere....

Question...how do I embed the .php in a style sheet? See, I'm totally
new at this. Though I'm learning (and I've taken the above pointers in
hand! Thanks!) I still don't quite know enough to take what he wrote
and make it work. (sighs)..

Okay, I'll try to work from here and see what I can do with it..and
I'll try to clean up that code some! I found it annoying to work with
also, but not knowing that much about .php, I didn't know if I could
take the comments out, nor can I find where the error is to just post
the problem.... etc....

Thanks! You guys are awesome!!

May 29 '06 #6
<La********@gmail.com> wrote in message
news:11**********************@u72g2000cwu.googlegr oups.com...
Question...how do I embed the .php in a style sheet? See, I'm totally
new at this. Though I'm learning (and I've taken the above pointers in
hand! Thanks!) I still don't quite know enough to take what he wrote
and make it work. (sighs)..

It works just the opposite. You embed the stylesheet into the php, not vice
versa. :)
place the following tag into your php sourcecode somewhere in the
<head></head> section: <link rel="stylesheet" type="text/css"
href="mystyle.css" /> and write the css-rules into <mystyle.css>. There are
a few other ways to embed a stylesheet (style-tag, import) but that's the
basic case.

--
"ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" -lpk
sp**@outolempi.net | Gedoon-S @ IRCnet | rot13(xv***@bhgbyrzcv.arg)
May 29 '06 #7
Here a link you may find very useful for learning CSS:

http://www.w3schools.com/css/default.asp

May 30 '06 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

24 posts views Thread by Ministry Of Jute | last post: by
2 posts views Thread by Chris M. Gamble | last post: by
12 posts views Thread by Nobody | last post: by
1 post views Thread by Sajid | last post: by
2 posts views Thread by Sonnich | last post: by
23 posts views Thread by Frank Millman | last post: by
reply views Thread by kermitthefrogpy | last post: by
reply views Thread by zattat | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.