mysql - Displaying result of same column but having different values in php -


I have the following php code that queries the database of my database according to the place. The table structure is as follows:

  s / n | List number | No Property. Location ===== +======================================= 1 | 125 A | 5245 | London 2 | 1254b. 7545 | London 3 | 128a. 5645 | New York 4 | 254b. 1545 | Tokyo 5 | 6545 | 1456 | Tokyo   

and code:

  $ location = $ _ POST ['loc']; Foreign currency ($ location $ chk1) {echo "
"; $ Sql ​​= "SELECT * from desktop where place = '$ chk1';"; $ Result = mysql_query ($ SQL); If ($ result == zero) {echo '& lt; Script & gt; Warning ("No entry for the place". $ Chk1. 'Anditem' .desktopreturned "); ; Continue;; $ Row = mysql_fetch_array ($ result); if ($ line = = Null) {echo '& lt; script & gt; warning ("no entry for the place. $ Chk1." And the item'. Desktop returned '); ;; Continue; } Mysql_data_seek ($ result, 0);? & Gt; & lt; table limit = '1' id = "desktop" caption = & lt ;? php $ location? & Gt; & gt; & lt; tr & gt; & gt; & gt; S / N & lt; / th & gt; & lt; th & gt; Inventory Number & lt; / th & gt; & lt; th & gt; Asset Number & lt; / th & Gt; & lt; Place & gt; Place & lt; / th & gt; & lt; / tr & gt; & lt ;? php while ($ row = mysql_fetch_array ($ result)) {? & Gt; tr class = "alt "& Gt; & lt ;? php echo '& lt; Td> ". $ Line ['s / n']" & lt; / TD & gt; "; echo" & lt; Td & gt; ". $ Line ['inventory no']" & lt; / TD & gt; "; echo" & lt; Td> ". $ Line ['asset number']" & lt; / TD & gt; "; echo" & lt; Td & gt; ". $ Line ['place']" & lt; / TD & gt; "; echo" & lt; / Tr> ";} resounds" & lt; / Table> ";}

Edit: CSS code:

  #desktop {font-family:" Trebuchet MS ", Ariel, Helvetica, Sans Serif; width: 100%; boundary-fall: collapse;} #desktop th {font-size: 1.1em; text align: left; padding-top: 5px; padding-bottom : 4px; Background color: # FFCC 33; Color: #ffffff;} #desktop td, #desktop th {font-size: 1em; boundary: 1 px solid # ffcc 33; padding: 3px 7px 2px 7px;} #desktop tr .alt td {color: # 000000; background color: #FFFFCC;}   

here, selected as $ location html

The results of the return of the query should be differently displayed in the form of a table, it is currently displaying the result of different place as well as its There are different tables with table-maters, I have to add the returned query to a variable.

This code Try with, I've changed the location to the default array by London,

Ild changed case name should be the first letter capital hope this help :)

  $ location = array ( 'London', 'Tokyo'); $ Str = '& Lt; Table range = "1" id = "desktop" & gt; & Lt; TR & gt; & Lt; Th & gt; S / N & lt; / Th & gt; & Lt; Th & gt; Inventory Number & lt; / Th & gt; & Lt; Th & gt; Asset no & lt; / Th & gt; & Lt; Th & gt; Place & lt; / Th & gt; & Lt; / TR & gt; '; Foreign currency ($ location $ chk1) {echo "
"; $ Sql ​​= "SELECT * from desktop where place = '$ chk1';"; $ Result = mysql_query ($ SQL); If ($ result == zero) {echo '& lt; Script & gt; Warning ("No entry for the place". $ Chk1. 'Anditem' .desktopreturned "); ; Continue;; $ Row = mysql_fetch_array ($ result); if ($ line = = Null) {echo '& lt; script & gt; warning ("no entry for the place. $ Chk1." And the item'. Desktop returned '); ;; Continue; } Mysql_data_seek ($ result, 0); while ($ line = mysql_fetch_array ($ result)) {$ str. = '& Lt; tr class = "alt" & gt; & lt; td & gt;' $ line [ 'Sr'] '& lt; / td & gt; & lt; td & gt;'. $ Line ['inventory_no'] '& lt; / td & gt; & lt; td & gt;'. ['Asset_no'] '& lt; / td & gt; & lt; td & gt;'. $ Line ['location'] '& lt; / td> gt; & lt; / tr & gt;'; }} $ Str. = '& Lt; / table & gt;'; Copy $ str;? & Gt;

Comments

Popular posts from this blog

c# - Textbox not clickable but editable -

php - how to change mysql_result($res, 0, "url"); to mysqli -

Matlab transpose a table vector -