cavey5 Posted April 20, 2007 Share Posted April 20, 2007 I have a simple search form where the user can enter a word. It is just an html page that has one text box and one submit button. It uses POST to send the word to the next page. My problem is that when I echo the results to a blank html page, with no formatting or tables, all the data shows up. But when I echo the same exact code to my page that has tables, only one of the two values show up. My query is as follows: [pre] $findsubscriber = "(SELECT cm_firstname, cm_status FROM subscriber_data WHERE cm_firstname = '$cm_subsearchterm')"; $findsubscriber_result= mysql_query($findsubscriber) OR die('QUERY ERROR: (mysql_error())); [/pre] and here is my display code: [pre] <? while ($row = mysql_fetch_array($findsubscriber_result)) { $cm_firstname = $row["cm_firstname"]; $cm_status = $row["cm_status"]; echo" Name: $cm_firstname<br/> Status: $cm_status<br/> "; } ?> [/pre] The result is: Name: Status: Active There is never a value for Name: - however if I just echo this to a blank white html page it shows up. That value cannot be empty or null, the form alerts you to enter it when adding a record. Could it be my style sheet eating my code? What in the heck is eating my data? My entire page code is below: [pre] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title></title> <link rel="stylesheet" href="pimpstyle.css" type="text/css" media="screen" /> </head> <body> <div class="container"> <div class="header"></div> <div class="main_right"> <div class="padded"> <div class="subnav"> </div> </div> </div> <div class="subnav1"> <br/><br/><br/> <div class="subnav3"> </div> </div> <div class="main" background: #dcdcdc;> <div class="formpadded"> <table width="480" height="200" bgcolor="#dcdcdc" cellpadding="0" cellspacing="0" align="left" valign="bottom" border="0"> <tr height="10"> <td colspan="3" height="30" bgcolor="#dcdcdc"> </td> </tr> <?php // Makes initial conection to database define ('DB_USER', '********'); define ('DB_PASSWORD', '********); define ('DB_HOST', '********'); define ('DB_NAME', '********'); $connect = @mysql_connect(DB_HOST, DB_USER, DB_PASSWORD) or die('Our database is currently down for updates, please check back later.'); $db = @mysql_select_db(DB_NAME, $connect) or die('Our database is currently down for updates, please check back later.'); // Aquires data source from form $cm_subsearchterm = $_POST['cm_subsearchterm']; // Selects data from the database $findsubscriber = "(SELECT cm_firstname, cm_status FROM subscriber_data WHERE cm_firstname = '$cm_subsearchterm')"; $findsubscriber_result= mysql_query($findsubscriber) OR die('QUERY ERROR:<br />' .$buy. '<br />' .mysql_error()); ?> <? while ($row = mysql_fetch_array($findsubscriber_result)) { $cm_lastname = $row["cm_firstname"]; $cm_status = $row["cm_status"]; echo" Name: $cm_firstname<br/> Status: $cm_status<br/> "; } ?> </table> </div> </div> <div class="clearer"><span></span></div> <div class="footer"> </div> </div> </body> </html> [/pre] Quote Link to comment Share on other sites More sharing options...
fenway Posted April 20, 2007 Share Posted April 20, 2007 Echo each part separately. Quote Link to comment 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.