Jump to content

layout problems...


blueman378

Recommended Posts

hi guys im using this code:

	echo '<table width="100%" height="100px" border="1" cellspacing="0" cellpadding="0">
	  <tr>
		<td>
';	

$query = mysql_query("SELECT * FROM shouts ORDER BY id DESC LIMIT 25") or die(mysql_error());
while ($row = mysql_fetch_array($query) )
{

	$name = stripslashes($row['Name']);
	$shout = stripslashes($row['Shout']);

    echo '<p><span><a href="userinfo.php?user='.$name.'" target="_blank">'.$name.'</a></span> - <span>'.$shout.'</span></p>';



} // while row mysqlfetcharray query


echo '
		</td>
	  </tr>
	  <tr>
		<td height="10"> </td>
		<form name="shout" method="post" ">
		  <div align="center">
							<input name="message" type="text" id="message" value="Message" size="25"><br>
			<input name="shout" type="submit" id="shout" value="Shout!">
		  </div>
		</form>
		</td>
	  </tr>
	  </table>

 

which works fine except for a few things,

1)looking at that layout it should be:

________________________________

| chat messages                            |

|                                                  |

|_______________________________|

|submit form                                  |

|_______________________________ |

 

but intead i get

chatform

___________________________________

|chat messages                                  |

|                                                      |

|__________________________________ |

|an empty row                                    |

|___________________________________|

 

2) chat messages i want it to be height-200 width -250 and have overflow auto,

and have the chat submit where the empty row,

 

i posted it here because it has php and didnt know if i should post it here or the html forum

Link to comment
Share on other sites

You have an extra </td> in there. Sometimes it helps to format the code so you can catch things like that easier.

 

echo('<table width="100%" height="100px" border="1" cellspacing="0" cellpadding="0">
<tr>
	<td>');	

	$query = mysql_query("SELECT * FROM shouts ORDER BY id DESC LIMIT 25") or die(mysql_error());
	while ($row = mysql_fetch_array($query))
	{
		$name = stripslashes($row['Name']);
		$shout = stripslashes($row['Shout']);

    		echo('<p><span><a href="userinfo.php?user='.$name.'" target="_blank">'.$name.'</a></span> - <span>'.$shout.'</span></p>');

	}
	// while row mysqlfetcharray query
	echo('</td>
</tr>
<tr>
	<td height="10">
	<form name="shout" method="post" ">
		<div align="center">
			<input name="message" type="text" id="message" value="Message" size="25"><br>
			<input name="shout" type="submit" id="shout" value="Shout!">
		</div>
	</form>
	</td>
</tr>
</table>');

Link to comment
Share on other sites

thanks thats made it look proper,

but any ideas on the overflow?

 

as i dont want to have a box 25 lines long,

but want to have 25 results

 

also i am getting one more strange thing,

here is the complete code:

<?php
// defining getShouts() which is our function that gets all of our shouts
function getShouts()
{
global $database;

echo('<table width="100%" height="100px" border="1" cellspacing="0" cellpadding="0">
<tr>
	<td>');	

	$query = mysql_query("SELECT * FROM shouts ORDER BY id DESC LIMIT 25") or die(mysql_error());
	while ($row = mysql_fetch_array($query))
	{
		$name = stripslashes($row['Name']);
		$shout = stripslashes($row['Shout']);

    		echo('<p><span><a href="userinfo.php?user='.$name.'" target="_blank">'.$name.'</a></span> - <span>'.$shout.'</span></p>');

	}
	// while row mysqlfetcharray query
	echo('</td>
</tr>
<tr>
	<td height="10">
	<form name="shout" method="post" ">
		<div align="center">
			<input name="message" type="text" id="message" value="Message" size="25"><br>
			<input name="shout" type="submit" id="shout" value="Shout!">
		</div>
	</form>
	</td>
</tr>
</table>');

} // function getshouts


// our processing if control statement
if ( isset ( $_POST['shout'] ) )
{

$name = $session->username;
	$message =  $_POST['message'];

if ( ( isset($name) ) && ( isset($message) ) )
{

	// getting smilie list
	$smilies = mysql_query("SELECT * FROM smilies") or die(mysql_error());
	while($get = mysql_fetch_array ($smilies))
	{

		$alt = $get['Alt'];
		$smilie = $get['URL'];

		$message = str_replace( $get['Symbol'] , '<img src="Smilies/'.$smilie.'" border="0" width="15" height="15" alt="'.$alt.'">' , $message);
		$themessage = addslashes($message);

		// replacing all smilies

	}

	mysql_query("INSERT INTO shouts (Name, Shout) VALUES ( '$name' ,  '$message' )") or die(mysql_error());
	$_SESSION['has_posted'] = 'yes';
	header("Location: index.php");

	// if required fields aren't empty, process into database

} 



} // if isset post shout

/* STARTING THE MAIN SCRIPT NOW */

// starting the table

//displaying the shouts


?>

 

and heres the strange thing:strangenm4.jpg

see the grey on it,

whats causing that?

 

Link to comment
Share on other sites

also note this part:

// getting smilie list
	$smilies = mysql_query("SELECT * FROM smilies") or die(mysql_error());
	while($get = mysql_fetch_array ($smilies))
	{

		$alt = $get['Alt'];
		$smilie = $get['URL'];

		$message = str_replace( $get['Symbol'] , '<img src="Smilies/'.$smilie.'" border="0" width="15" height="15" alt="'.$alt.'">' , $message);
		$themessage = addslashes($message);

		// replacing all smilies

 

its no working,

 

i have two images in the Smilies dir, Good.png and Bad.png,

the database table name is smilies,

it looks like this

____________________________

|ID |Symbol| URL        | Alt        |

---------------------------------

|1  |:)      |Good.png  |Good.png|

|2  |:(      |Bad.png    |Bad.png  |

----------------------------------

 

but it doesnt work,

i get no errors it just doesnt replace them

 

any ideas

Link to comment
Share on other sites

well i have done some changes so here it is:

<?php
// defining getShouts() which is our function that gets all of our shouts
function getShouts()
{
global $database;
echo "<P align='center'>";
	$query = mysql_query("SELECT * FROM smilies ORDER BY Symbol DESC") or die(mysql_error());
	while ($row = mysql_fetch_array($query))
	{ echo '|   <img width="15px" height="15px" src="Smilies/'.$row[url].'" alt="'.$row[symbol].'"> ~ <b>'.$row[symbol].'</b>   |';
	};
echo('</P><table width="100%" height="100px" border="1" cellspacing="0" cellpadding="0">
<tr>
	<td>');	

	$query = mysql_query("SELECT * FROM shouts ORDER BY id DESC LIMIT 25") or die(mysql_error());
	while ($row = mysql_fetch_array($query))
	{
		$name = stripslashes($row['Name']);
		$shout = stripslashes($row['Shout']);

    		echo('<p><a href="userinfo.php?user='.$name.'" target="_blank">'.$name.'</a> - '.$shout.'</p>');

	}
	// while row mysqlfetcharray query
	echo('</td>
</tr>
<tr>
	<td height="10">
	<form name="shout" method="post" ">
		<div align="center">
			<input name="message" type="text" id="message" value="Message" size="55"><br>
			<input name="shout" type="submit" id="shout" value="Shout!">
		</div>
	</form>
	</td>
	');
        	echo('
</tr>
</table>');

} // function getshouts


// our processing if control statement
if ( isset ( $_POST['shout'] ) )
{

$name = $session->username;
	$message =  $_POST['message'];

if ( ( isset($name) ) && ( isset($message) ) )
{

	// getting smilie list
	$smilies = mysql_query("SELECT * FROM smilies") or die(mysql_error());
	while($get = mysql_fetch_array ($smilies))
	{

		$alt = $get['Alt'];
		$smilie = $get['URL'];

		$message = str_replace( $get['Symbol'] , '<img src="Smilies/'.$smilie.'" border="0" width="15" height="15" alt="'.$alt.'">' , $message);
		$themessage = addslashes($message);

		// replacing all smilies

	}

	mysql_query("INSERT INTO shouts (Name, Shout) VALUES ( '$name' ,  '$message' )") or die(mysql_error());
	$_SESSION['has_posted'] = 'yes';
	header("Location: index.php");

	// if required fields aren't empty, process into database

} 



} // if isset post shout

/* STARTING THE MAIN SCRIPT NOW */

// starting the table

//displaying the shouts


?>

 

the only problem i have left is a wish to have the <td> containing the messages have an overflow and have it fixed height of about 5 lines

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.