show PHP with database connection

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I have problem with showing my php code.
This is my code:

  mysql_connect ("$dbhost","$username","$dbww");
  mysql_select_db ("$db") or die ("Foutje");

   $resultaat = mysql_query ("SELECT DISTINCT vragen.vraag_id,
vragen.vraag_omschrijving, antwoord_omschrijving, antwoord_code FROM
vragen,antwoorden WHERE vragen.vraag_id = antwoorden.vraag_id;");
  while ($record = mysql_fetch_array($resultaat))
      $q="SELECT COUNT(vraag_id) FROM antwoorden WHERE

     echo "<br>$record[vraag_id].<br>";
      echo "$record[vraag_omschrijving]<br>";
      echo "{";

echo "$record[antwoord_omschrijving],";

    if ($record[$antwoord_code] == 1){
    print (" =");
    } else if ($record[$antwoord_code] == 0){
    print (" ~");    echo "}";}}

The result in HTML is:
{antwoord_1, =antwoord_2, ~antwoord_3, ~antwoord_4, ~
{antwoord_1, ~antwoord_2, =antwoord_3, ~antwoord_4, ~

But it has to be like this:
{=antwoord_1, ~antwoord_2, ~antwoord_3, ~antwoord_4}

Can anyone get it like above?

Re: show PHP with database connection

i am not getting what exactly you have to do

Re: show PHP with database connection

I have a database with questions and answers. For each answer stands
the answercode 0(fault) or 1(correct) If it is a 1 then a = must be
fore the answer and if it is a 0 then a ~ must be for the answer.
The answer must be separated by a comma and at the beginning and at the
endt a .

Like this:
{=antwoord_1, ~antwoord_2, ~antwoord_3, ~antwoord_4}

Re: show PHP with database connection

You can find the code and database on

Site Timeline