# Hello, i need to get onlyone value from the second select, in the select case of the table, primo for the only 1° case td and the others blank, secondo for the 2° and other blank etc..one selection for each. Someone can help me please.?

**URL:** <https://www.phphelp.com/t/hello-i-need-to-get-onlyone-value-from-the-second-select-in-the-select-case-of-the-table-primo-for-the-only-1-case-td-and-the-others-blank-secondo-for-the-2-and-other-blank-etc-one-selection-for-each-someone-can-help-me-please/36399>\
**Category:** Beginners - Learning PHP\
**Created:** [February 23, 2025, 2:16am UTC](https://www.phphelp.com/t/hello-i-need-to-get-onlyone-value-from-the-second-select-in-the-select-case-of-the-table-primo-for-the-only-1-case-td-and-the-others-blank-secondo-for-the-2-and-other-blank-etc-one-selection-for-each-someone-can-help-me-please/36399 "2025-02-23T02:16:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![stylelab](https://www.phphelp.com/user_avatar/www.phphelp.com/stylelab/32/459_2.png) [@stylelab](https://www.phphelp.com/u/stylelab)\
**Post date:** [February 23, 2025, 2:16am UTC](https://www.phphelp.com/t/hello-i-need-to-get-onlyone-value-from-the-second-select-in-the-select-case-of-the-table-primo-for-the-only-1-case-td-and-the-others-blank-secondo-for-the-2-and-other-blank-etc-one-selection-for-each-someone-can-help-me-please/36399/1 "2025-02-23T02:16:13Z")

</div>

```auto
<html>
	
	<body bgcolor="white">
	
   <font face='courier'>
	<font color='red'>
	
	<form action='test.php' method='GET'>
<select id="op" name="ops">
<option value="">seleziona....</option>
<option value="a">a</option>
<option value="b">b</option>
<option value="c">c</option>
<option value="d">d</option>
</select>

		<div class="input"><input type="text" name="nbusta" value="" id="input_nbusta" />
	</div>

<select id="tipo" name="tipos">
<option value="">Seleziona...</option>
<option value="primo">primo</option>
<option value="secondo">Secondo</option>
<option value="cambio">Cambio</option>

</select>

	
	<hr/><br/><br/>
	<input type='submit' value='vai'>
	<input type='reset' value='Reset'>
	</form>
	</body>
</html> 
```

[//test.php](https://test.php)

```auto
<html>
<meta charset="UTF-8">
<head></head>
<body bgcolor='white'>
	
<font face='Courier'>
<font color='red'>
<br><br>
<hr size=2>
<?php
     $date=date('d M Y');
     $nome=$_GET['ops'];
     $nbusta=$_GET['nbusta'];
     $primo=$_GET['tipos'];
     $secondo1=$_GET['secondo1'];
     $cambio2=$_GET['tipos'];
     
    //prima riga Gialla della tabella: Descrizione
    echo date('d M Y');
    echo "<br><br><hr>";
    echo "<table border=1>";
    echo "<tr bgcolor='yellow' align='center'>";
    	echo "<td>Data</td>";
    	echo "<td>Operatore</td>";
        echo "<td>N°Busta</td>";
	echo "<td>1°st</td>";
	echo "<td>2°nd</td>";
	echo "<td>3°</td>";
	
    echo "</tr>";
    
        {
	echo "<tr bgcolor='white' align='center'>";
        echo "<td>$date</td>";
    	echo "<td>$nome</td>";
	echo "<td>$nbusta</td>";
	echo "<td>$primo</td>";
        echo "<td>$secondo</td>";
        echo "<td>$cambio</td>";
        
         }
 
?>
<br><br><hr>
<center>
</body>
</html>
```

---

<div class="post-metadata">

**Author:** ![phdr](https://www.phphelp.com/letter_avatar_proxy/v4/letter/p/91b2a8/32.png) [@phdr](https://www.phphelp.com/u/phdr)\
**Post date:** [February 23, 2025, 12:35pm UTC](https://www.phphelp.com/t/hello-i-need-to-get-onlyone-value-from-the-second-select-in-the-select-case-of-the-table-primo-for-the-only-1-case-td-and-the-others-blank-secondo-for-the-2-and-other-blank-etc-one-selection-for-each-someone-can-help-me-please/36399/2 "2025-02-23T12:35:55Z")

</div>

`$_GET['tipos']` will either be - `"", "primo", "secondo", or "cambio"`.

You can see what the submitted data is by using -

```auto
echo '<pre>'; print_r($_GET); echo '</pre>';
```

You would use conditional logic to test what value $\_GET[‘tipos’] is to produce each of the `<td></td>` elements with either the value you want or an empty string.

Php has a ternary operator that can be used to write simple if/else logic in-line.

Based on what I think you are trying to do, I would use -

```auto
echo "<td>".($_GET['tipos'] == "primo" ? $_GET['tipos'] : '')."</td>";
echo "<td>".($_GET['tipos'] == "secondo" ? $_GET['tipos'] : '')."</td>";
echo "<td>".($_GET['tipos'] == "cambio" ? $_GET['tipos'] : '')."</td>";
```

---

<div class="post-metadata">

**Author:** ![stylelab](https://www.phphelp.com/user_avatar/www.phphelp.com/stylelab/32/459_2.png) [@stylelab](https://www.phphelp.com/u/stylelab)\
**Post date:** [February 23, 2025, 4:37pm UTC](https://www.phphelp.com/t/hello-i-need-to-get-onlyone-value-from-the-second-select-in-the-select-case-of-the-table-primo-for-the-only-1-case-td-and-the-others-blank-secondo-for-the-2-and-other-blank-etc-one-selection-for-each-someone-can-help-me-please/36399/3 "2025-02-23T16:37:10Z")

</div>

Ok!! Thank you a lot!!  
😀

---

<div class="post-metadata">

**Author:** ![stylelab](https://www.phphelp.com/user_avatar/www.phphelp.com/stylelab/32/459_2.png) [@stylelab](https://www.phphelp.com/u/stylelab)\
**Post date:** [February 23, 2025, 5:50pm UTC](https://www.phphelp.com/t/hello-i-need-to-get-onlyone-value-from-the-second-select-in-the-select-case-of-the-table-primo-for-the-only-1-case-td-and-the-others-blank-secondo-for-the-2-and-other-blank-etc-one-selection-for-each-someone-can-help-me-please/36399/4 "2025-02-23T17:50:24Z")

</div>

But if i want to print “1” like quantity 1 instead primo, secondo and cambio? Like this picture

 ![20250223_184459](https://www.phphelp.com/uploads/default/original/2X/f/f9620bde844890c0fedef4ce00e18152a28ea4fe.jpeg)

---

<div class="post-metadata">

**Author:** ![phdr](https://www.phphelp.com/letter_avatar_proxy/v4/letter/p/91b2a8/32.png) [@phdr](https://www.phphelp.com/u/phdr)\
**Post date:** [February 24, 2025, 12:27am UTC](https://www.phphelp.com/t/hello-i-need-to-get-onlyone-value-from-the-second-select-in-the-select-case-of-the-table-primo-for-the-only-1-case-td-and-the-others-blank-secondo-for-the-2-and-other-blank-etc-one-selection-for-each-someone-can-help-me-please/36399/5 "2025-02-24T00:27:49Z")

</div>

One would hope that you would examine the code and learn how it works, so that if you want to change the value that gets used you can do so yourself. The documentation for the ternary operator can be found at this link - [PHP: Comparison - Manual](https://www.php.net/manual/en/language.operators.comparison.php)
