views:

69

answers:

3

Hi

i am trying to get data from db, but in while loop, first data is coming blank, let me show you

<?php
$query = "SELECT * FROM `artists` WHERE label_id = '$id' ORDER BY name";

$result = mysql_query($query);



while ($info = mysql_fetch_array($result)) {

?>

    <option value="<?php echo $info['ID']; ?>"><?php echo $info['name']; ?></option>

   <?php 
        }
 ?>

here first $info['ID'] data of the row is missing, $info['name'] is ok but ID is missing.

where am i wrong you think ?

thx

+2  A: 

Check the value keys (if it's not $info['id'] for example).

If it's still not working add after the while this row

print_r($info); die();

In this mode you will see what $info contains (if there is no id, check the query).

Alekc
yes there is ID, but why "<option value=" doesnt have it?
Ahmet vardar
i am getting the selectbox value with this "var aid = $("#artist").val();" maybe this cause that ?
Ahmet vardar
ok sorry my mistake in jquery code, thx so much
Ahmet vardar
You may try $('#artist:selected').val() or $('#artist:selected').text()
jerjer
A: 

Your ID field is really called label_id. Try:

<?php echo $info['label_id']; ?>
Andomar
yes i am sure i want to get ID field
Ahmet vardar
Omg... I was so sure you just got the name wrong. Cheers :)
Andomar
A: 

Are you sure that the value="x" is missing , the feeling i am getting is that there is something wrong with ur javascript and its not getting the value from the selectbox and based on that you think that the value is missing .. can u view the html source of the output and view in that if the options actually have the value in them .. also posting ur table schema will be helpful.

Sabeen Malik