我有这个SQL查询:
$sql1="SELECT articoli.sconto_st as promozione, marche.ID,marche.marca, categorie.ID,articoli.marche_ID,articoli.categorie_ID,categorie.categoria
FROM articoli,categorie, marche
AND articoli.categorie_ID=categorie.ID
AND articoli.marche_ID=marche.ID
AND marca='$marcavalue'
AND categoria='$categoriavalue'
";
$result1=mysqli_query($con,$sql1);
我想输出一些数据:
<?php
while($row1=mysqli_fetch_array($result1)) {
echo "<tr>";
echo '<td class="tab1"><b>'. $row1["marca"] . '<b> '. $row1["promozione"].'</b> </br></td>'; //scala
echo "</tr>";
我想选择上面查询中的所有数据,但是只有当它是1时才输出promozione。所以要选择其他数据,但只有当它是1时,才会输出promozione。不同于1只输出马卡。有没有办法做到这一点?
答案 0 :(得分:0)
public class ExpandableList extends AppCompatActivity {
private static final String Shared = null;
ExpandableListView expandableListView;
ExpandableListAdapter expandableListAdapter;
String expandableListTitle;
ArrayList<String> expandableListDetail;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.expandable_list);
expandableListDetail = getIntent().getStringArrayListExtra("Options");
expandableListTitle = getIntent().getStringExtra("Heading");
expandableListAdapter = new CustomExpandableListAdapter(this, expandableListTitle, expandableListDetail);
expandableListView.setAdapter(expandableListAdapter);
expandableListView.setOnGroupExpandListener(new ExpandableListView.OnGroupExpandListener() {
@Override
public void onGroupExpand(int groupPosition) {
Toast.makeText(getApplicationContext(),
expandableListTitle + " List Expanded.",
Toast.LENGTH_SHORT).show();
}
});
expandableListView.setOnGroupCollapseListener(new ExpandableListView.OnGroupCollapseListener() {
@Override
public void onGroupCollapse(int groupPosition) {
Toast.makeText(getApplicationContext(),
expandableListTitle + " List Collapsed.",
Toast.LENGTH_SHORT).show();
}
});
expandableListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
@Override
public boolean onChildClick(ExpandableListView parent, View v,
int groupPosition, int childPosition, long id) {
Toast.makeText(
getApplicationContext(),
expandableListTitle
+ " -> "
+ expandableListDetail/*.get(
expandableListTitle.get(groupPosition)).get(
childPosition)*/, Toast.LENGTH_SHORT
).show();
return false;
}
});
}}
这一行,我补充说:<?php
while($row1=mysqli_fetch_array($result1)) {
$promozione= ($row1['promozione'] == 1) ?1 :"";
echo "<tr>";
echo '<td class="tab1"><b>'. $row1["marca"] . '<b> '. $promozione.'</b> </br></td>'; //scala
echo "</tr>";
是简称:
$promosione = ($row1['promozione'] == 1) ?1 :"";
我希望这能解决你的问题。