blueman378 Posted December 31, 2007 Share Posted December 31, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/83821-layout-problems/ Share on other sites More sharing options...
thiggins09 Posted December 31, 2007 Share Posted December 31, 2007 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>'); Quote Link to comment https://forums.phpfreaks.com/topic/83821-layout-problems/#findComment-426527 Share on other sites More sharing options...
blueman378 Posted December 31, 2007 Author Share Posted December 31, 2007 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: see the grey on it, whats causing that? Quote Link to comment https://forums.phpfreaks.com/topic/83821-layout-problems/#findComment-426533 Share on other sites More sharing options...
blueman378 Posted December 31, 2007 Author Share Posted December 31, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/83821-layout-problems/#findComment-426540 Share on other sites More sharing options...
blueman378 Posted December 31, 2007 Author Share Posted December 31, 2007 ok well the grey was the span tags, Quote Link to comment https://forums.phpfreaks.com/topic/83821-layout-problems/#findComment-426545 Share on other sites More sharing options...
blueman378 Posted December 31, 2007 Author Share Posted December 31, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/83821-layout-problems/#findComment-426571 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.