← PHP

Ajuda com o codigo de php com if

Lida 2815 vezes

Offline

btt50 
Membro
Mensagens 3 Gostos 0
Troféus totais: 15
Trófeus: (Ver todos)
Super Combination Combination Topic Starter Level 3 Level 2 Level 1 First Post Karma Seventh year Anniversary Sixth year Anniversary

eu tenho o seguinte código e queria queria que ele muda-se a caixa consoante o tipo por exemplo aquela variável 'img' é files enquanto as outras são text alguém me pode ajudar com o código de if? 

Código: [Seleccione]
[pre]<form id="alterar" method="post" action="tentar.php">
<table align="center">

<tr>
<td class="admin2">Alterar o qu&ecirc;? </td>
<td><select name="cond" size=1>
                                                                          <option value="">Qual o campo para alterar</option>
  <option value="n_b">Nome</option>
  <option value="marca ">Marca</option>
  <option value="img"> Imagem</option>
</select ></td>
<td class="admin2" >Pelo quê?</td>
<td ><?php 
if() 
echo ("<input type='file' name='alt'/>");
else
echo ("<input type='text' name='alt'/>");

?>
</td>
</tr>
<tr>
<td class="admin2"> Identifique o usario por:  </td>
<td><select name="qual" size=1>
                                                                          <option value="">Qual o campo que o identifica</option>
  <option value="n_b">Numero do BI</option>
  <option value="marca">Mail</option>
  <option value="img">Password</option>
</select ></td>
<td class="admin2" >Palavra Chave:</td>
     <td ><input type="text" name="foi" /></td>
</tr>[/pre]
Obrigada fico a espera da resposta
Offline

mapb_1990 
Membro
Mensagens 109 Gostos 0
Feedback +2

Troféus totais: 26
Trófeus: (Ver todos)
Level 5 Tenth year Anniversary Windows User Super Combination Combination Topic Starter Poll Voter Level 4 Level 3 Level 2

para isso usa-se javascript.
tens k ir buscar o valor selecionado com DOM (getElementByID()) e depois fazer o tal isso mas com js
Offline

Souza 
Elite
Mensagens 1816 Gostos 1
Troféus totais: 28
Trófeus: (Ver todos)
Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4 Level 3 Level 2 Level 1

Convém escreveres bom Português para que se perceba o que queres.

PHP é server side, não vais conseguir fazer o que queres sem ter de fazer refresh à página, o ideal será utilizar javascript, investiga a framework jQuery, é espetacular.
Offline

btt50 
Membro
Mensagens 3 Gostos 0
Troféus totais: 15
Trófeus: (Ver todos)
Super Combination Combination Topic Starter Level 3 Level 2 Level 1 First Post Karma Seventh year Anniversary Sixth year Anniversary

Podem me arranjar uma amostra de código  por favor :o