S
S
SkeyPlay2015-04-18 16:55:46
PHP
SkeyPlay, 2015-04-18 16:55:46

How to pull the desired row from the database?

Here is the code:

<div class="form-group">
            <label for="game" class="col-sm-3 control-label">Игра:</label>
            <div class="col-sm-4">
              <select class="form-control" id="gameid" name="gameid" onChange="updateForm()">
                <?php foreach($games as $item): ?> 
                <option value="<?php echo $item['game_id'] ?>"><?php echo $item['game_name'] ?></option>
                <?php endforeach; ?> 
              </select>
            </div>
          </div>

It is necessary that only $item['game_id'] which = 1 is taken, the
rest 2,3,4,5,6.... game_id should not be taken!
How to implement?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Shua_inc, 2015-04-18
@Shua_inc

something like this

<div class="form-group">
            <label for="game" class="col-sm-3 control-label">Игра:</label>
            <div class="col-sm-4">
              <select class="form-control" id="gameid" name="gameid" onChange="updateForm()">
                <?php foreach($games as $item):
                          if($item['game_id'] ==1){?>
                                   <option value="<?=$item['game_id'] ?>"><?= $item['game_name'] ?></option>
                 <?} endforeach; ?> 
                 </select>
            </div>
          </div>

S
Sergey, 2015-04-18
@Pjeroo

select * from games where game_id = 1;
It is necessary?

A
Anyon1337, 2015-04-18
@Anyon1337

<?
$result = mysql_query("SELECT * FROM games WHERE game_id='$game_id'",$db);
?>
Here is an example of usage.
Just before that you need to connect the base.
Example:
<?
include('db.php');
?>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question