ignorant Posted October 2, 2007 Share Posted October 2, 2007 I am trying to display on record, two fields of the record. here is what I'm using: <?php require_once('../Connections/connectionpage.php'); ?> <?php mysql_select_db($database, $db) or die(mysql_error()); $Booth_Num = $_GET['WLE_booth']; $Company_Nam = $_GET['Company']; $Booth_Num = mysql_real_escape_string($Booth_Num); $Company_Nam = mysql_real_escape_string($Company_Nam); $query = "SELECT * FROM tablename WHERE WLE_booth = '$Booth_Num'"; $qry_result = mysql_query($query) or die(mysql_error()); $display_string = "<table>"; $display_string .= "<tr>"; $display_string .= "<th>Booth</th>"; $display_string .= "<th>Company</th>"; $display_string .= "</tr>"; while($row = mysql_fetch_array($qry_result)){ $display_string .= "<tr>"; $display_string .= "<td>$Booth_Num</td>"; $display_string .= "<td>$Company_Nam</td>"; $display_string .= "</tr>"; } $display_string .= "</table>"; echo $display_string; ?> Please help me before my boss fires me... Quote Link to comment https://forums.phpfreaks.com/topic/71525-so-frustrated-trying-to-display-record/ Share on other sites More sharing options...
pocobueno1388 Posted October 2, 2007 Share Posted October 2, 2007 I don't understand. You did a query, then used a while loop with that query, but your not even using that query within the while loop...that doesn't make sense to me. If your only expecting one result, then there is no need for a loop. <?php require_once('../Connections/connectionpage.php'); mysql_select_db($database, $db) or die(mysql_error()); $Booth_Num = $_GET['WLE_booth']; $Company_Nam = $_GET['Company']; $Booth_Num = mysql_real_escape_string($Booth_Num); $Company_Nam = mysql_real_escape_string($Company_Nam); $query = "SELECT * FROM tablename WHERE WLE_booth = '$Booth_Num'"; $qry_result = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_assoc($qry_result); $display_string = "<table>"; $display_string .= "<tr>"; $display_string .= "<th>Booth</th>"; $display_string .= "<th>Company</th>"; $display_string .= "</tr>"; $display_string .= "<tr>"; $display_string .= "<td>{$row['booth_num']}</td>"; $display_string .= "<td>{$row['company_nam']}</td>"; $display_string .= "</tr>"; $display_string .= "</table>"; echo $display_string; ?> Obviously you will need to fill in your own column name values from your database on the two variables I used. I'm not sure if this is what your looking for, but you can give it a try. Quote Link to comment https://forums.phpfreaks.com/topic/71525-so-frustrated-trying-to-display-record/#findComment-360108 Share on other sites More sharing options...
ignorant Posted October 2, 2007 Author Share Posted October 2, 2007 Yeah I'm new at this and trying to learn from a book and code snips. Your code doesn't give me an error, but it doesn't display anything. I know the field names are correct, but it just doesn't display anything. I'm getting frustrated. I don't understand. You did a query, then used a while loop with that query, but your not even using that query within the while loop...that doesn't make sense to me. If your only expecting one result, then there is no need for a loop. Obviously you will need to fill in your own column name values from your database on the two variables I used. I'm not sure if this is what your looking for, but you can give it a try. Quote Link to comment https://forums.phpfreaks.com/topic/71525-so-frustrated-trying-to-display-record/#findComment-360122 Share on other sites More sharing options...
MmmVomit Posted October 2, 2007 Share Posted October 2, 2007 You want something like this. <?php require_once('../Connections/connectionpage.php'); ?> <?php // connect to database mysql_select_db($database, $db) or die(mysql_error()); $Booth_Num = $_GET['WLE_booth']; $Company_Nam = $_GET['Company']; $Booth_Num = mysql_real_escape_string($Booth_Num); $Company_Nam = mysql_real_escape_string($Company_Nam); $query = "SELECT * FROM tablename WHERE WLE_booth = '$Booth_Num'"; $qry_result = mysql_query($query) or die(mysql_error()); $display_string = "<table>"; $display_string .= "<tr>"; $display_string .= "<th>Booth</th>"; $display_string .= "<th>Company</th>"; $display_string .= "</tr>"; while($row = mysql_fetch_assoc($qry_result)){ // $Booth_Num and $Company_Nam still contain GET data // $row contains data retrieved from the database // you need to actually reference $row to use any of that data $display_string .= "<tr>"; $display_string .= "<td>$row[WLE_booth]</td>"; $display_string .= "<td>$row[company_name]</td>"; $display_string .= "</tr>"; } $display_string .= "</table>"; echo $display_string; ?> Quote Link to comment https://forums.phpfreaks.com/topic/71525-so-frustrated-trying-to-display-record/#findComment-360126 Share on other sites More sharing options...
ignorant Posted October 2, 2007 Author Share Posted October 2, 2007 Yeah, still nothing displays...no idea. You want something like this. Quote Link to comment https://forums.phpfreaks.com/topic/71525-so-frustrated-trying-to-display-record/#findComment-360158 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.