ganesh8686 Posted March 15, 2013 Share Posted March 15, 2013 (edited) Hi I have small search php code in this i want to display the result in vertical. i have mentioned the code below. Can anyone help me to get the result. Thanks in advance!! <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "[url=http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd]http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd[/url]"> <?php include ("menu.php"); ?> <div id="content"> <div id="primaryContentContainer"> <div id="primaryContent"> <h2>Search Results<span></span></h2> <?php //capture search term and remove spaces at its both ends if the is any $searchTerm = trim($_GET['keyname']); //check whether the name parsed is empty if($searchTerm == "") { echo "Enter key word you are searching for."; exit(); } //database connection info $host = "localhost"; //server $db = "market_codes"; //database name $user = "root"; //dabases user name $pwd = ""; //password //connecting to server and creating link to database $link = mysqli_connect($host, $user, $pwd, $db); //MYSQL search statement $query = "SELECT * FROM allo WHERE description LIKE '%$searchTerm%'"; $results = mysqli_query($link, $query); /* check whethere there were matching records in the table by counting the number of results returned */ if(mysqli_num_rows($results) >= 1) { $output = ""; while($row = mysqli_fetch_array($results)) { $output .= "Sl No: " . $row['sl_no'] . "<br />"; $output .= "Category: " . $row['category'] . "<br />"; $output .= "Description: " . $row['description'] . "<br />"; $output .= "Outlet: " . $row['outlet'] . "<br />"; $output .= "Trading Area: " . $row['ta'] . "<br />"; $output .= "Food CSI: " . $row['food'] . "<br />"; $output .= "Drug CSI: " . $row['drug'] . "<br />"; $output .= "Mass Census: " . $row['mass'] . "<br />"; $output .= "xAOC Co: " . $row['xaoc'] . "<br />"; $output .= "Deca Census: " . $row['deca'] . "<br />"; $output .= "Sam's Census: " . $row['sma_s'] . "<br />"; $output .= "BJ's Census: " . $row['bj_s'] . "<br />"; $output .= "Dollar Gen Cen: " . $row['dollar'] . "<br />"; $output .= "Family Dol Cen: " . $row['family'] . "<br />"; $output .= "Fred Dol Cen: " . $row['fred'] . "<br />"; $output .= "Walmart Mass Cen: " . $row['walmart_mass'] . "<br />"; $output .= "Walmart Food Cen: " . $row['walmart_food'] . "<br /><br />"; } echo $output; } else echo "There was no matching record for the query " . $searchTerm; ?> Edited March 16, 2013 by ignace Added code tags Quote Link to comment https://forums.phpfreaks.com/topic/275699-coding-help/ Share on other sites More sharing options...
davidannis Posted March 15, 2013 Share Posted March 15, 2013 What is not working? Do you get an error message? Quote Link to comment https://forums.phpfreaks.com/topic/275699-coding-help/#findComment-1418828 Share on other sites More sharing options...
ganesh8686 Posted March 15, 2013 Author Share Posted March 15, 2013 (edited) It is working fine. I want to dispaly the result in table formate. The above code result is coming horizontal. I want the result would be in vertically like the below code. Please let me know if need further information. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "[url=http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd]http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd[/url]"> <?php include ("menu.php"); ?> <?php session_start(); ?> <div id="content"> <div id="primaryContentContainer"> <div id="primaryContent"> <h2>Sample Trading Area<span></span></h2> <?php mysql_connect("localhost","root","");//database connection mysql_select_db("market_codes"); $query = "SELECT * FROM allo where category='Sample TA'"; $result = mysql_query($query) or die(mysql_error()); $num=mysql_numrows($result); mysql_close(); ?> <table> <tr class="rowB"> <th>Sl No</th> <th>Description</th> <th>Outlet</th> <th>Trading Area</th> <th>Food CSI</th> <th>Reportable</th> <th>Drug CSI</th> <th>Reportable</th> <th>Mass Census</th> <th>xAOC Co</th> <th>Deca Census</th> <th>Sam's Census</th> <th>BJ's Census</th> <th>Dollar Gen Cen</th> <th>Family Dol Cen</th> <th>Fred Dol Cen</th> <th>Walmart Mass Cen</th> <th>Walmart Food Cen</th> </tr> <?php $i=0; while ($i < $num) { $t1=mysql_result ($result, $i, "sl_no"); $t2=mysql_result ($result, $i, "description"); $t3=mysql_result ($result, $i, "outlet"); $t4=mysql_result ($result, $i, "ta"); $t5=mysql_result ($result, $i, "food"); $t6=mysql_result ($result, $i, "report"); $t7=mysql_result ($result, $i, "drug"); $t8=mysql_result ($result, $i, "reportt"); $t9=mysql_result ($result, $i, "mass"); $t10=mysql_result ($result, $i, "xaoc"); $t11=mysql_result ($result, $i, "deca"); $t12=mysql_result ($result, $i, "sma_s"); $t13=mysql_result ($result, $i, "bj_s"); $t14=mysql_result ($result, $i, "dollar"); $t15=mysql_result ($result, $i, "family"); $t16=mysql_result ($result, $i, "fred"); $t17=mysql_result ($result, $i, "walmart_mass"); $t18=mysql_result ($result, $i, "walmart_food"); ?> <tr class="rowA"> <td><?php echo $t1 ?></td> <td><?php echo $t2 ?></td> <td><?php echo $t3 ?></td> <td><?php echo $t4 ?></td> <td><?php echo $t5 ?></td> <td><?php echo $t6 ?></td> <td><?php echo $t7 ?></td> <td><?php echo $t8 ?></td> <td><?php echo $t9 ?></td> <td><?php echo $t10 ?></td> <td><?php echo $t11 ?></td> <td><?php echo $t12 ?></td> <td><?php echo $t13 ?></td> <td><?php echo $t14 ?></td> <td><?php echo $t15 ?></td> <td><?php echo $t16 ?></td> <td><?php echo $t17 ?></td> <td><?php echo $t18 ?></td> </tr> <?php $i++; } ?> Edited March 16, 2013 by ignace Added code tags Quote Link to comment https://forums.phpfreaks.com/topic/275699-coding-help/#findComment-1418839 Share on other sites More sharing options...
davidannis Posted March 16, 2013 Share Posted March 16, 2013 (edited) Do you have a </table> ? Can you post the source (html) of the output? Edited March 16, 2013 by davidannis Quote Link to comment https://forums.phpfreaks.com/topic/275699-coding-help/#findComment-1418940 Share on other sites More sharing options...
ignace Posted March 16, 2013 Share Posted March 16, 2013 Please read the forum guidelines before posting. Always surround posted code with code tags. Quote Link to comment https://forums.phpfreaks.com/topic/275699-coding-help/#findComment-1418966 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.