473,405 Members | 2,141 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

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 1664


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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

24
by: Ministry Of Jute | last post by:
I returned home from work today to find an Airborne Express Letter Express mailer leaning up against my apartment door. The return addressee was Microsoft Suite 300 1165 Eastlake Avenue E...
2
by: Chris M. Gamble | last post by:
I am trying to perform what I best understand as Multi-master asynchronous replication for postgres 7.3.3 servers. After researching, I tried the pgReplication project (and made the simple...
12
by: Nobody | last post by:
DB2 500G database, Wintel, heavily loaded OLTP (5M+ transactions a day; all transactions are extremely small, all selects are controlled (no ad-hoc), 99% of all selects are very small (no table...
1
by: Sajid | last post by:
Hello! Experts, I have the following piece of code in VB.NET that I want to use to update any records in the database. I would like to use a code as well as DataGrid to update the records....
7
by: Aaron | last post by:
Complete code follows. I am new to .NET programming (and programming in general) and I am having a difficult time understanding how to fill a variable in one sub, and then access it from...
5
by: Janning Vygen | last post by:
Hi, tonight my database got corruppted. before it worked fine. since two days i do the following tasks every night psql -c 'CLUSTER;' $DBNAME psql -c 'VACUUM FULL ANALYZE;' $DBNAME ...
2
by: Sonnich | last post by:
Hi all! I am still playing around with databases. So here it goes: Is packing needed for MySQL (5.0)? I have a new DB, which already is 178 MB. Will that continue to grow, when I add and...
23
by: Frank Millman | last post by:
Hi all I have a small problem. I have come up with a solution, but I don't know if it is a) safe, and b) optimal. I have a class with a number of attributes, but for various reasons I cannot...
0
by: Chuck W1CEW | last post by:
So we have a MySQL database that suddenly started reporting "can't open *.ibd file" errors on InnoDB tables in phpMyAdmin. (MyISAM are fine). To recover the data is all I want at this point -- so...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.