How do I get PHP variables from this MySQL query? -


I am working on an asset database problem using PHP / MySQL.

In this script I would like to search my assets by asset assets and return it to all related areas.

Firstly I check the database property table and find the asset type. Then depending on the type, I run 1 out of 3 questions.

  & lt ;? Php // mebase database mysql_connect ("localhost", "asset_db", "asset_db") or die (mysql_error ()); Mysql_select_db ("asset_db") or die (mysql_error ()); // Type the property type = mysql_query (type asset type from "asset WHERE asset.id = 93120") or die (mysql_error ()); Switch ($ type) {case "server": // some things that include a mysql query mysql_query ("SELECT asset.id, asset.company, asset.location, asset.purchase_date, asset.purchase_order, asset.value, property Server, ID, SAP, SAP, SAP, SAP, SAP, SAP, SAP, SAP, SAP ID = 93120 "); break; Case "laptop": // There are some things that include a mysql query mysql_query ("SELECT asset.id, asset.company, asset.location, asset.purchase_date, asset.purchase_order, asset.value, asset.Type, asset.notes Laptop on Laptop.manufacturer, laptop.model, laptop.serial_number, laptop.esc, laptop.user, laptop.prev_user, laptop.warranty Laptop on laptop. Id = asset.id where asset.id = 93120 ") ; break; Case "Desktop": // Some things that include a mysql query mysql_query ("SELECT asset.id, asset.company, asset.location, asset.purchase_date, asset.purchase_order, asset.value, asset.type, asset.notes Desktop, desktop, desktop, desktop, aerial_number, desktop.ac, desktop user, desktop.preve_user, desktop.DTD on desktop desktop on desktop .id = asset.id where asset.id = 93120 " ); break; }? & Gt;  

So far, I am able to get the property. Type in $ type How do I get the remaining variables ($ model from laptop model, $ Notes to asset.notes and so on)?

Thank you.

  $ sql = "your query"; $ Res = mysql_query ($ sql); While ($ line = mysql_fetch_assoc ($ res)) {echo 'start record & lt; Br / & gt; '; Echo ['type'] per line '& Lt; Br / & gt; '; Echo ['company'] per line '& Lt; Br /> ';; Echo ['location'] per line '& Lt; Br / & gt; '; Eco and Android & lt; Br / & gt; & Lt; Br / & gt; '; }  

Try to see what you want, you can use the data if you wish;

You may also want to look at mysql_fetch_array , click on mysql_fetch_row or mysql_fetch_object . Choose what is best for your needs.


Comments