0

I wrote a php script to obtain the biography of a musical group. The resulting JSON has a property named "musicians" which must be a list of musicians. I do like this:

$group["musician"] = mysqli_fetch_array($group["nombre_musico"]." ".$group[apellidos_musico].", ");

where:

$mysqli = mysqli_connect("localhost","root","","bd_tfg");

and:

$sql = "select gr.nombre_grupo, gr.anyo_creacion, gr.descripcion, ms.nombre_musico, ms.apellidos_musico\n"
. "from musico ms, canta_para cp, grupo gr\n"
. "where ms.id_musico = cp.musico_id and gr.id_grupo = cp.grupo_id and gr.nombre_grupo = \'oreja van gogh\'";

I hope for a little help to perform this.

3
  • 3
    Read the php manual about mysql_fetch_array(). It doesn't do what you think it does. ch1.php.net/manual/en/mysqli-result.fetch-array.php Commented Jul 30, 2014 at 22:32
  • 1
    Your Question is lacking the Question! Commented Jul 30, 2014 at 22:34
  • How is a JSON resulted here? Commented Jul 30, 2014 at 22:36

1 Answer 1

1

You need to execute the query after your mysqli_connect, and then fetch the values... something like this:

$mysqli = new mysqli_connect("localhost","root","","bd_tfg");
$sql = "..."; (your query)
$result = $mysqli->query($sql);
$group = $result->fetch_array(MYSQLI_ASSOC);

And then, you can do, if you like:

$group["musician"] = $group["nombre_musico"]." ".$group["apellidos_musico"];
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.