Help php code [easy]

Gestart doorJorzwa5 reacties37 weergaven

6 berichten · pagina 1 van 1

Jorzwa

Lid · Topicstarter

Berichten
1.644
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Hallo,

ik ben bezig met een sms site maar ik kom uit 1ding niet bloos
als je niet bent ingelogd moet er hallo gast staan en als je bent ingelogd moet er je saldo staan voor die saldo heb ik wel een phpscripje gemaakt

Je Saldo is [COLOR= #0000BB]<?
$query[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"SELECT * FROM users WHERE id = "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$memberid[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$result[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]
[URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$object[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_object"]mysql_fetch_object[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$result[/COLOR][COLOR= #007700])){[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$object[/COLOR][COLOR= #007700]->[/COLOR]saldo[COLOR= #007700];
}[/COLOR]
?>


dus wie kan me helpen dat zo te maken wat is hier boven heb vermeld?bloos
0
Berichten
515
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?php[/COLOR]

[COLOR= #FF8000]//als inlog sessie niet bestaat[/COLOR]
[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700](![/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]login[/COLOR][COLOR= #007700]])) {[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]hallo droplul registreer je[/COLOR][COLOR= #007700];
}[/COLOR]
[URL="http://www.php.net/else"]else[/URL][COLOR= #007700]{[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Je Saldo is:[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$query[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"SELECT * FROM users WHERE id = "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$memberid[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$result[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]
[URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$object[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_object"]mysql_fetch_object[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$result[/COLOR][COLOR= #007700])){[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$object[/COLOR][COLOR= #007700]->[/COLOR]saldo[COLOR= #007700];
}[/COLOR]

?>
0
Berichten
6.144
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Als je mensen laat inloggen op je site, welke informatie/sessies/cookies geef je dan mee?

Is wel handig om te weten, kunnen wij het voor je aanpassen.
0
Berichten
4.451
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ik heb ook ooit zon script gehad. Maar bij mij lag het probleem bij de $query
Ik deed:

Je Saldo is [COLOR= #0000BB]<?
$query[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM users WHERE id = "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$memberid[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]
[URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$object[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_object"]mysql_fetch_object[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700])){[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$object[/COLOR][COLOR= #007700]->[/COLOR]saldo[COLOR= #007700];
}[/COLOR]
?>


En toen deed hij t
maar waarom zo moeilijk doen met whiles etc.?
dit kan toch ook?:

[COLOR= #0000BB]<?php
$query[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM users WHERE id = "[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$memberid[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #DD0000]""[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]
[COLOR= #0000BB]$fetch[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]Je saldo is [/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$fetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]saldo[/COLOR][COLOR= #007700]] .[/COLOR][COLOR= #DD0000][/COLOR][COLOR= #007700];[/COLOR]
?>
0
Berichten
6.144
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Met een while werkt overzichtelijker.

En zoals in jouw bericht mysql_fetch_assoc(); werkt sneller als mysql_fetch_object();.
0
Berichten
18.482
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Maar een while is nergens voor nodig als je maar 1 row uit de database haalt
0

Jouw reactie

Deel je idee, stel een vraag of help een ander verder.

Editor laden…

Praat mee met de One2xs-community.

Inloggen om te reageren