473,404 Members | 2,137 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

show PHP with database connection

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

include("verbinding.php");
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;");
$i=1;
while ($record = mysql_fetch_array($resultaat))
{
if($i==1)
{
$q="SELECT COUNT(vraag_id) FROM antwoorden WHERE
vraag_id=".$record[0];
$q_result=mysql_query($q);
$aantal=mysql_fetch_row($q_result);

echo "<br>$record[vraag_id].<br>";
echo "$record[vraag_omschrijving]<br>";
echo "{";
}
$antwoord_code="antwoord_code";
echo "$record[antwoord_omschrijving],";
if($i==$aantal[0])
{
$i=1;
}
else
$i++;

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

The result in HTML is:
1
vraag_1
{antwoord_1, =antwoord_2, ~antwoord_3, ~antwoord_4, ~
2
vraag_2
{antwoord_1, ~antwoord_2, =antwoord_3, ~antwoord_4, ~

But it has to be like this:
1
vraag_1
{=antwoord_1, ~antwoord_2, ~antwoord_3, ~antwoord_4}
Can anyone get it like above?

Dec 1 '05 #1
3 1313
i am not getting what exactly you have to do

Dec 1 '05 #2
PHP
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 {and}.

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

Dec 5 '05 #3
PHP
You can find the code and database on http://gtxp.rickwedzinga.nl/

Dec 5 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Mudge | last post by:
Hi, My hosting provider only allows me to use 50 connections to my MySQL database that my Web site will use. I don't know what this 50 connections means exactly. Does this mean that only 50...
14
by: Nick Gilbert | last post by:
Hi, I have an asp.net application which runs from a CD-ROM using Cassini. As such, it is single user only. The application connects to an Access database when it is loaded, and keeps the same...
15
by: Joachim | last post by:
Hi, Als a beginner, I am looking for a way to show records My code is Private sub Connection( Dim odbconn_Pro As OleDbConnectio Dim odbcomm_Pro As OleDbComman Dim odbdare_Pro As...
0
by: mel_apiso | last post by:
Hi, after uncatalog one database, and catalog again with other name, if I try to connect with this database, everything is ok, but list applications only show me the connection with the...
35
by: Terry Jolly | last post by:
Web Solution Goal: Have a global database connection Why: (There will be 30+ tables, represented by 30+ classes) I only want to reference the database connection once. I put the connection...
6
by: gerbski | last post by:
Hi all, I am relatively new to ADO, but up to now I got things working the way I wanted. But now I've run into somethng really annoying. I am working in MS Access. I am using an Access...
39
by: alex | last post by:
I've converted a latin1 database I have to utf8. The process has been: # mysqldump -u root -p --default-character-set=latin1 -c --insert-ignore --skip-set-charset mydb mydb.sql # iconv -f...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.