Re: beginner: why does this not work
| From: | H Marc Bower | Date: | Tue, 06 May 2003 19:54:45 +0000 |
| Subject: | Re: beginner: why does this not work | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-19783@lists.php.net to get a copy of this message | ||
A couple of possibilities...
If you're selecting everything from your table, just use "select * from
persoon" - won't cause your problem, but it's a little quicker to type. :)
I'm not sure why you reassign the array variables to new variable names -
you can simply use the existing array to display them. However, I have
never needed to put the field names in quotes when fetching an array. So,
instead of $rij["voornaam"], try $rij[voornam]. If that doesn't make any
difference, you may have to tack your print strings together like so,
although you *should* be able to call the variable from within the quotes
but I have had problems with it before (and brackets are OK, just not
required):
print "<tr><td width='100%' bgcolor='white'><font
size='2'>VOORNAAM: ".
$rij[voornaam];
Try that.
(V)
----- Original Message -----
From: "cablenews.casema.net" <staafmixer@wanadoo.nl>
To: <php-windows@lists.php.net>
Sent: Thursday, May 01, 2003 9:26 PM
Subject: [PHP-WIN] beginner: why does this not work
> Maybe a beginner question....
> Could someone please explain to me why this code doesn't work? I really
> don't get it...
>
> Greetz Tristan.
>
> <html>
>
> <head><title>persoon administratie</title>
> <body>
>
> <?php
>
> //the database-connection works
> mysql_connect ('localhost','','');
> mysql_select_db("tristan");
>
> //selecting every colomn in the database.
> $query = "SELECT voornaam, achternaam, adres, adres_nr, postcode,
> woonplaats, telefoonnr, geslacht, notitie, id FROM persoon";
> $result = mysql_query($query);
>
> //this is where my error occurs
> while ($rij = mysql_fetch_array($result)) {
>
> $voornaam = $rij["voornaam"];
> $achternaam = $rij["achternaam"];
> $adres = $rij["adres"];
> $adresnr = $rij["adres_nr"];
> $postcode = $rij["postcode"];
> $woonplaats = $rij["woonplaats"];
> $telefoonnr = $rij["telefoonnr"];
> $geslacht = $rij["geslacht"];
> $notitie = $rij["notitie"];
> $id = $rij["id"];
>
>
> print ("<center><table border='2' width='100%'
> bordercolor='black'
> cellspacing='1'>\n");
> print ("<tr><td width='100%' bgcolor='white'><font
> size='2'>VOORNAAM:
> $voornaam");
> print ("<tr><td width='100%' bgcolor='white'><font
> size='2'>ACHTERNAAM:
> $achternaam");
> print ("<tr><td width='100%' bgcolor='white'><font
> size='2'>ADRES:
> $adres");
> print ("<tr><td width='100%' bgcolor='white'><font
> size='2'>ADRESNR:
> $adresnr");
> print ("<tr><td width='100%' bgcolor='white'><font
> size='2'>POSTCODE:
> $postcode");
> print ("<tr><td width='100%' bgcolor='white'><font
> size='2'>WOONPLAATS:
> $woonplaats");
> print ("<tr><td width='100%' bgcolor='white'><font
> size='2'>TELEFOONNR:
> $telefoonnr");
> print ("<tr><td width='100%' bgcolor='white'><font
> size='2'>GESLACHT:
> $geslacht");
> print ("<tr><td width='100%' bgcolor='white'><font
> size='2'>NOTITIE:
> $notitie");
> print("</table></center><br><br>\n\n");
>
> }
>
>
>
> ?>
>
> </body>
> </html>
>
>
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>