Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

html table problem

Status
Not open for further replies.

zinja

MIS
Nov 14, 2002
149
US
I am trying to get the image to show in a row next to the form, instead of above it. The image (realtorsmall.gif) is showing on the left and the form on the right, but the image is above the form. How do I get the image to show beside the form? Here is my code...
Code:
echo table_header ( $lang['Realtor_Search'], ' <img src="templates/default/images/realtor_logo_small.gif" width="17" height="21">' );

echo '
<form action="' . URL . '/usersearch.php" method="POST">
 <table width="100%" cellpadding="5" cellspacing="0" border="0">
     ';
echo '	<tr>
       <td width="70%" align="left" valign="top" <img src="templates/default/images/RealtorSmall.gif">
	   </td>
</tr>';
echo userform ($lang['Realtor_First_Name'], '<input type="text" size="45" name="realtor_first_name" maxlength="255">');
echo userform ($lang['Realtor_Last_Name'], '<input type="text" size="45" name="realtor_last_name" maxlength="255">');
echo userform ($lang['Realtor_Company_Name'], '<input type="text" size="45" name="realtor_company_name" maxlength="255">');
echo userform ($lang['Search_Keyword'], '<input type="text" size="45" name="realtor_description" maxlength="100">');
echo userform ($lang['Location'], '<select name="realtor_location"><option value="ANY" SELECTED>' . $lang['Search_Any'] . ' ' . $lang['Location'] . '</option>' . generate_options_list(LOCATIONS_TABLE) . '</select>');
echo userform ($lang['City'], '<input type="text" size="45" name="realtor_city" maxlength="50">');
echo userform ($lang['Zip_Code'], '<input type="text" size="45" name="realtor_zip_code" maxlength="20">');

// Submit button
echo userform ('', '<input type="Submit" name="realtor_search" value="' . $lang['Realtor_Search'] . '">');

echo '
 </table>
</form>
';


LJ Wilson

My personal saying - Just remember, it can always get worse, and usually will.
 
One way is to actually put your form in the same table row<tr> as the image.
Code:
[b][s]</td>
</tr>[/s][/b]';
echo userform ($lang['Realtor_First_Name'], '<input type="text" size="45" name="realtor_first_name" maxlength="255">');
echo userform ($lang['Realtor_Last_Name'], '<input type="text" size="45" name="realtor_last_name" maxlength="255">');
echo userform ($lang['Realtor_Company_Name'], '<input type="text" size="45" name="realtor_company_name" maxlength="255">');
echo userform ($lang['Search_Keyword'], '<input type="text" size="45" name="realtor_description" maxlength="100">');
echo userform ($lang['Location'], '<select name="realtor_location"><option value="ANY" SELECTED>' . $lang['Search_Any'] . ' ' . $lang['Location'] . '</option>' . generate_options_list(LOCATIONS_TABLE) . '</select>');
echo userform ($lang['City'], '<input type="text" size="45" name="realtor_city" maxlength="50">');
echo userform ($lang['Zip_Code'], '<input type="text" size="45" name="realtor_zip_code" maxlength="20">');

// Submit button
echo userform ('', '<input type="Submit" name="realtor_search" value="' . $lang['Realtor_Search'] . '">');

echo 
[b]</td>
</tr>[/b]'
 </table>
but I wouldn't use a table here at all. I'd use css and float the image to the left, but use whatever you're comfortable with.

Greg
"Personally, I am always ready to learn, although I do not always like being taught." - Winston Churchill
 
I tried what you mentioned and wound up with an error msg. I changed it to:

Code:
echo table_header ( $lang['Realtor_Search'], ' <img src="templates/default/images/realtor_logo_small.gif" width="17" height="21">' );

echo '
<form action="' . URL . '/usersearch.php" method="POST">
 <table width="100%" cellpadding="5" cellspacing="0" border="0">
     ';
echo '	<tr>
       <td width="70%" align="left" valign="top" <img src="templates/default/images/RealtorSmall.gif">';
echo userform ($lang['Realtor_First_Name'], '<input type="text" size="45" name="realtor_first_name" maxlength="255">');
echo userform ($lang['Realtor_Last_Name'], '<input type="text" size="45" name="realtor_last_name" maxlength="255">');
echo userform ($lang['Realtor_Company_Name'], '<input type="text" size="45" name="realtor_company_name" maxlength="255">');
echo userform ($lang['Search_Keyword'], '<input type="text" size="45" name="realtor_description" maxlength="100">');
echo userform ($lang['Location'], '<select name="realtor_location"><option value="ANY" SELECTED>' . $lang['Search_Any'] . ' ' . $lang['Location'] . '</option>' . generate_options_list(LOCATIONS_TABLE) . '</select>');
echo userform ($lang['City'], '<input type="text" size="45" name="realtor_city" maxlength="50">');
echo userform ($lang['Zip_Code'], '<input type="text" size="45" name="realtor_zip_code" maxlength="20">');

// Submit button
echo userform ('', '<input type="Submit" name="realtor_search" value="' . $lang['Realtor_Search'] . '">');

echo'
</td>
</tr>
</table>
</form>';

But it still is displayed wrong (the same as before). If I need to do this as you mentioned, how would I do it? I am new to PHP and how it interacts with html. All help is greatly appreciated.

LJ Wilson

My personal saying - Just remember, it can always get worse, and usually will.
 
Try putting it in separate cells in the table for a start
Code:
<td width="70%" align="left" valign="top" <img src="templates/default/images/RealtorSmall.gif">[b]</td><td>[/b]';

Greg
"Personally, I am always ready to learn, although I do not always like being taught." - Winston Churchill
 
Thanks for the help, I tried that and it still didn't work. The image is still at the top left and the form fields are below and to the right of it. Here is what I have now )after the change):
Code:
echo table_header ( $lang['Realtor_Search'], ' <img src="templates/default/images/realtor_logo_small.gif" width="17" height="21">' );

echo '
<form action="' . URL . '/usersearch.php" method="POST">
 <table width="100%" cellpadding="5" cellspacing="0" border="0">
     ';
echo '	<tr>
       <td width="40%" align="left" valign="top" <img src="templates/default/images/RealtorSmall.gif"></td><td>';
echo userform ($lang['Realtor_First_Name'], '<input type="text" size="45" name="realtor_first_name" maxlength="255">');
echo userform ($lang['Realtor_Last_Name'], '<input type="text" size="45" name="realtor_last_name" maxlength="255">');
echo userform ($lang['Realtor_Company_Name'], '<input type="text" size="45" name="realtor_company_name" maxlength="255">');
echo userform ($lang['Search_Keyword'], '<input type="text" size="45" name="realtor_description" maxlength="100">');
echo userform ($lang['Location'], '<select name="realtor_location"><option value="ANY" SELECTED>' . $lang['Search_Any'] . ' ' . $lang['Location'] . '</option>' . generate_options_list(LOCATIONS_TABLE) . '</select>');
echo userform ($lang['City'], '<input type="text" size="45" name="realtor_city" maxlength="50">');
echo userform ($lang['Zip_Code'], '<input type="text" size="45" name="realtor_zip_code" maxlength="20">');

// Submit button
echo userform ('', '<input type="Submit" name="realtor_search" value="' . $lang['Realtor_Search'] . '">');

echo'
</td>
</tr>
</table>
</form>';

LJ Wilson

My personal saying - Just remember, it can always get worse, and usually will.
 
What happens if you close your td tag in this line?
Code:
<td width="70%" align="left" valign="top"[b][COLOR=red]>[/color][/b] <img src="templates/default/images/RealtorSmall.gif">';
 
Makes no difference. Thanks though, any other ideas? I am sure this is something simple, I just don't know what is it :D?

LJ Wilson

My personal saying - Just remember, it can always get worse, and usually will.
 
can you post the resultant html source code?
 
Is this what you mean (I viewed the page source of that page):
Code:
<form action="[URL unfurl="true"]http://msprogramming.com/armls/usersearch.php"[/URL] method="POST">
 <table width="100%" cellpadding="5" cellspacing="0" border="0">
     	<tr>
       <td width="40%" align="left" valign="top"> <img src="templates/default/images/RealtorSmall.gif"></td><td>

   <tr>
    <td width="30%" align="right" valign="top">
     First Name
    </td>

    <td width="70%" align="left" valign="top">
     <input type="text" size="45" name="realtor_first_name" maxlength="255">
    </td>
   </tr>
	

   <tr>
    <td width="30%" align="right" valign="top">
     Last Name
    </td>
    <td width="70%" align="left" valign="top">

     <input type="text" size="45" name="realtor_last_name" maxlength="255">
    </td>
   </tr>
	

   <tr>
    <td width="30%" align="right" valign="top">
     Company Name
    </td>
    <td width="70%" align="left" valign="top">
     <input type="text" size="45" name="realtor_company_name" maxlength="255">

    </td>
   </tr>
	

   <tr>
    <td width="30%" align="right" valign="top">
     Keyword
    </td>
    <td width="70%" align="left" valign="top">
     <input type="text" size="45" name="realtor_description" maxlength="100">
    </td>

   </tr>
	

   <tr>
    <td width="30%" align="right" valign="top">
     State
    </td>
    <td width="70%" align="left" valign="top">
     <select name="realtor_location"><option value="ANY" SELECTED>Any State</option><option value="1">Arkansas</option><option value="2">Louisiana</option><option value="3">Mississippi</option><option value="4">Missouri</option><option value="5">Oklahoma</option><option value="6">Texas</option></select>

    </td>
   </tr>
	

   <tr>
    <td width="30%" align="right" valign="top">
     City
    </td>
    <td width="70%" align="left" valign="top">
     <input type="text" size="45" name="realtor_city" maxlength="50">
    </td>

   </tr>
	

   <tr>
    <td width="30%" align="right" valign="top">
     Zip / Postal Code
    </td>
    <td width="70%" align="left" valign="top">
     <input type="text" size="45" name="realtor_zip_code" maxlength="20">
    </td>
   </tr>

	

   <tr>
    <td width="30%" align="right" valign="top">
     
    </td>
    <td width="70%" align="left" valign="top">
     <input type="Submit" name="realtor_search" value="Find A Realtor">
    </td>
   </tr>
	
</td>
</tr>

</table>
</form>

LJ Wilson

My personal saying - Just remember, it can always get worse, and usually will.
 
You're starting a new row, so, of course, the form will be on a lower line:
Code:
<td width="40%" align="left" valign="top"> <img src="templates/default/images/RealtorSmall.gif"></td><td>

   [COLOR=blue][b]<tr>[/b][/color]
    <td width="30%" align="right" valign="top">
     First Name
    </td>

Greg
"Personally, I am always ready to learn, although I do not always like being taught." - Winston Churchill
 
I see that, but how do I get php to not do that? I need new rows for each of the fields in the form, but want the image to be to the left of the entire form. If you look at my php code, it is not specifying a new row.

LJ Wilson

My personal saying - Just remember, it can always get worse, and usually will.
 
you need to have a look at your userform() function. it is generating the extra table row. if you post that function then we may be able to help
 
Here is the whole page of code.

Code:
// Include configuration file and general functions
include ( './config.php' );
include ( PATH . '/defaults.php' );

// ----------------------------------------------------------------------
// ADVANCED SEARCH SECTION

// Title tag content
$title = $conf['website_name_short'] . ' - ' .  $lang['Realtor_Search'];

// Template header
include ( PATH . '/templates/' . $cookie_template . '/header.php' );

// Output the Find a Realtor form
echo table_header ( $lang['Realtor_Search'], ' <img src="templates/default/images/realtor_logo_small.gif" width="17" height="21">' );

echo '
<form action="' . URL . '/usersearch.php" method="POST">
 <table width="100%" cellpadding="5" cellspacing="0" border="0">
     ';
echo '	<tr>
       <td width="40%" align="left" valign="top"> <img src="templates/default/images/RealtorSmall.gif"></td><td>';
echo userform ($lang['Realtor_First_Name'], '<input type="text" size="45" name="realtor_first_name" maxlength="255">');
echo userform ($lang['Realtor_Last_Name'], '<input type="text" size="45" name="realtor_last_name" maxlength="255">');
echo userform ($lang['Realtor_Company_Name'], '<input type="text" size="45" name="realtor_company_name" maxlength="255">');
echo userform ($lang['Search_Keyword'], '<input type="text" size="45" name="realtor_description" maxlength="100">');
echo userform ($lang['Location'], '<select name="realtor_location"><option value="ANY" SELECTED>' . $lang['Search_Any'] . ' ' . $lang['Location'] . '</option>' . generate_options_list(LOCATIONS_TABLE) . '</select>');
echo userform ($lang['City'], '<input type="text" size="45" name="realtor_city" maxlength="50">');
echo userform ($lang['Zip_Code'], '<input type="text" size="45" name="realtor_zip_code" maxlength="20">');

// Submit button
echo userform ('', '<input type="Submit" name="realtor_search" value="' . $lang['Realtor_Search'] . '">');

echo'
</td>
</tr>
</table>
</form>';

echo table_footer ();

// Template Footer
include ( PATH . '/templates/' . $cookie_template . '/footer.php' );

?>
Thanks for working with me on this. I may be ignorant of the problem, but trust me I have tried to figure this out.

LJ Wilson

My personal saying - Just remember, it can always get worse, and usually will.
 
you have a function in scope called userform(). if it is not on this page then it must be in one of the ¨included¨ pages. i would guess that it is in the file called default.php but it could also be in config.php or header.php
 
I found it. What I think I want to do is to fix it and rename it to myuserform(). Can you help me fix it?
Code:
// --------------------------------------------------------------------------
// USERFORM()
// This function creates cells for Name and Field for
// the forms

function userform ( $name, $field, $required = '' )

 {

  $output = '

   <tr>
    <td width="30%" align="right" valign="top">
     ' . $name;

   // If the field is required we add the red asterisk
   if ($required == '1')
    $output.= ' <span class="warning">*</span> ';

   $output.= '
    </td>
    <td width="70%" align="left" valign="top">
     ' . $field . '
    </td>
   </tr>
	';

  return $output;

 }

LJ Wilson

My personal saying - Just remember, it can always get worse, and usually will.
 
we are now at the root of the problem.

to fix it can you clarify where you actually want the image? to one side of the whole form, in place of one of the field labels or where?
 
and can you also post the table_header() function code?
 
I want the image to appear on the left and the form fields (including names) on the right. Currently the image is on the top left and the form fields are on the bottom right (below the image). Here is table_header function:
Code:
// COMMON CONTENT TABLE HEADER
// - this html code is added to all the content tables
// as a header by using echo table_header('Name');
function table_header ( $message )

 {

  global $cookie_template;

  $return = '

      <table border="0" cellpadding="0" cellspacing="0" width="100%">
       <tr>
        <td>
         <img src="' . URL . '/templates/' . $cookie_template . '/images/ug_white_lt.gif" alt="" height="10" width="10"><br>
        </td>
        <td class="line_white_top" colspan="3" width="100%">
         <img src="' . URL . '/templates/' . $cookie_template . '/images/x.gif" alt="" height="1" width="1"><br>
        </td>
        <td>
         <img src="' . URL . '/templates/' . $cookie_template . '/images/ug_white_rt.gif" alt="" height="10" width="10"><br>
        </td>			
       </tr>
       <tr>
        <td class="line_white_left">
         <img src="' . URL . '/templates/' . $cookie_template . '/images/x.gif" alt="" height="1" width="1">
        </td>
        <td colspan="3" valign="top" align="left">

         <span class="table_header_text"> &nbsp;'
          . $message .
         '</span>

         <table width="100%" cellpadding="5" cellspacing="0" border="0">
          <tr>
           <td align="left" width="100%">
  	    <br>

     ';

  return $return;

 }

LJ Wilson

My personal saying - Just remember, it can always get worse, and usually will.
 
there are a number of ways to skin the cat. here is a simple solution but ideally you would migrate to css.

change this line in the header
Code:
function table_header ( $message, $image=¨¨ )
{
  $width = empty($image) ? ¨100%¨ : ¨75%¨;
  global $cookie_template;

  $return = $image . '
      
      <table border="0" cellpadding="0" cellspacing="0" width="'.$width.'">

just make sure that the dimensions of the image are less than 25% of the width of the page (or change the 75% to whatever you want.
 
I changed that and am now getting the following error message.

Notice: Undefined variable: width in /srv/ on line 69

Line 69 is:
Code:
 <table border="0" cellpadding="0" cellspacing="0" width="'.$width.'">

Here is the code from tables.php (I created a new function because I didn't want to change the other pages, only this one).
Code:
function table_header_image ( $message, $image="" )

 {
  $widthe=empty($image) ? "100%" : "75%"; 	
  global $cookie_template;

  $return = $image . '

      <table border="0" cellpadding="0" cellspacing="0" width="'.$width.'">
       <tr>
        <td>
         <img src="' . URL . '/templates/' . $cookie_template . '/images/ug_white_lt.gif" alt="" height="10" width="10"><br>
        </td>
        <td class="line_white_top" colspan="3" width="100%">
         <img src="' . URL . '/templates/' . $cookie_template . '/images/x.gif" alt="" height="1" width="1"><br>
        </td>
        <td>
         <img src="' . URL . '/templates/' . $cookie_template . '/images/ug_white_rt.gif" alt="" height="10" width="10"><br>
        </td>			
       </tr>
       <tr>
        <td class="line_white_left">
         <img src="' . URL . '/templates/' . $cookie_template . '/images/x.gif" alt="" height="1" width="1">
        </td>
        <td colspan="3" valign="top" align="left">

         <span class="table_header_text"> &nbsp;'
          . $message .
         '</span>

         <table width="100%" cellpadding="5" cellspacing="0" border="0">
          <tr>
           <td align="left" width="100%">
  	    <br>

     ';

  return $return;

 }

And here is the code from realtorsearchform.php (the page that has the image and form)
Code:
<?php
// Include configuration file and general functions
include ( './config.php' );
include ( PATH . '/defaults.php' );

// ----------------------------------------------------------------------
// ADVANCED SEARCH SECTION

// Title tag content
$title = $conf['website_name_short'] . ' - ' .  $lang['Realtor_Search'];

// Template header
include ( PATH . '/templates/' . $cookie_template . '/header.php' );

// Output the Find a Realtor form
echo table_header_image ( $lang['Realtor_Search'], ' <img src="templates/default/images/realtor_logo_small.gif" width="17" height="21">' );

echo '
<form action="' . URL . '/usersearch.php" method="POST">
 <table width="100%" cellpadding="5" cellspacing="0" border="0">
     ';
echo '	<tr>
       <td width="40%" align="left" valign="top"> <img src="templates/default/images/RealtorSmall.gif"></td><td>';
echo armlsuserform ($lang['Realtor_First_Name'], '<input type="text" size="45" name="realtor_first_name" maxlength="255">');
echo armlsuserform ($lang['Realtor_Last_Name'], '<input type="text" size="45" name="realtor_last_name" maxlength="255">');
echo armlsuserform ($lang['Realtor_Company_Name'], '<input type="text" size="45" name="realtor_company_name" maxlength="255">');
echo armlsuserform ($lang['Search_Keyword'], '<input type="text" size="45" name="realtor_description" maxlength="100">');
echo armlsuserform ($lang['Location'], '<select name="realtor_location"><option value="ANY" SELECTED>' . $lang['Search_Any'] . ' ' . $lang['Location'] . '</option>' . generate_options_list(LOCATIONS_TABLE) . '</select>');
echo armlsuserform ($lang['City'], '<input type="text" size="45" name="realtor_city" maxlength="50">');
echo armlsuserform ($lang['Zip_Code'], '<input type="text" size="45" name="realtor_zip_code" maxlength="20">');

// Submit button
echo armlsuserform ('', '<input type="Submit" name="realtor_search" value="' . $lang['Realtor_Search'] . '">');

echo'
</td>
</tr>
</table>
</form>';

echo table_footer ();

// Template Footer
include ( PATH . '/templates/' . $cookie_template . '/footer.php' );

?>

Any ideas?


LJ Wilson

My personal saying - Just remember, it can always get worse, and usually will.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top