[PHP] resultaat in $

Gestart doorAntonn26 reacties61 weergaven

27 berichten · pagina 1 van 2

Antonn

Lid · Topicstarter

Berichten
8.649
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Hoe krijg ik het resultaat van de volgende code:

[COLOR= #0000BB]<?php
$table[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]insert[/COLOR][COLOR= #007700]]);[/COLOR]
[COLOR= #0000BB]$dbname[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"wax_systeem"[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$fields[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_listfields"]mysql_listfields[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$dbname[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$table[/COLOR][COLOR= #007700]);[/COLOR]

[COLOR= #0000BB]$field_num[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_num_fields"]mysql_num_fields[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$fields[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$i[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #0000BB]0[/COLOR][COLOR= #007700];[/COLOR]

[URL="http://www.php.net/while"]while[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$i[/COLOR] [COLOR= #007700]<[/COLOR] [COLOR= #0000BB]$field_num[/COLOR][COLOR= #007700]) {[/COLOR]
        [COLOR= #0000BB]$name[/COLOR]  [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_field_name"]mysql_field_name[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$fields[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$i[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$name[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$a[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$i[/COLOR] [COLOR= #007700]+[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$a[/COLOR] [COLOR= #007700]!=[/COLOR] [COLOR= #0000BB]$field_num[/COLOR][COLOR= #007700]) {[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]","[/COLOR][COLOR= #007700];
}[/COLOR]
    [COLOR= #0000BB]$i[/COLOR][COLOR= #007700]++;
}[/COLOR]
?>


in dit: $fieldss

echo $fieldss; moet dit dus geven:
field1, field2, field3, field4
0
Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
$var = inhoud, ;
$var .= inhoud2, ;

Waarbij je de 2e var in die while zet?
0
Antonn

Lid · Topicstarter

Berichten
8.649
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ik snap het niet? Kan je het niet voor me maken? AAUUBB??
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
Je kan zelf toch ook proberen hypocriteZo heb ik het ook 7 jaar geleden geleerd.
0
Berichten
5.957
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
$fieldss = $field1.$field2.$field3.$field4;
0
Antonn

Lid · Topicstarter

Berichten
8.649
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ik kan er echt niet aan uit?
0
Antonn

Lid · Topicstarter

Berichten
8.649
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
BUMP, echt niemand dit voor mij kan maken confused??
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
Zou ik mogen vragen wat je nou eigenlijk wilt bereiken?

Je staat een aantal genummerde velden te tellen, wat weer duidt op een slecht ontworpen datamodel.
Als je vertelt wat je precies wilt doen, kan ik kijken of ik een gepaster advies kan geven, en of wat je wilt, wel goed is.
0
Berichten
35.796
Reputatie
1
Punten
0,00
Lid sinds
Laatst gezien
Inderdaad, als je kolommen met de naam field1, field2, field3, field4, enzovoort in je database hebt dan doe je hoogstwaarschijnlijk wat fout qua opzet.
0
Antonn

Lid · Topicstarter

Berichten
8.649
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Kijk, de bovenste lange code die daar staat... Als ik die ergens zet geeft dat iets als dit weer: "tabel1, tabel2, tabel3". Maar dat resultat wil ik dus in een variable.
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
Geef eens antwoord op mijn vraag.
Wat is je doel, en wat maak je? Ik heb het idee dat je flink de verkeerde weg in bent geslagen.

Als een applicatie afhangt van het aantal velden of tabellen, dan klopt je database-structuur niet.
0
Antonn

Lid · Topicstarter

Berichten
8.649
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ik wil alle fields van een tabel met komma ertussen in variable hebben. Op het einde geen komma dus, alleen ertussen.

toevoeging op 23 januari 2012, 16:42:03:
Kan dit misschien met function?

[COLOR= #0000BB]<?php[/COLOR]
[COLOR= #007700]function[/COLOR] Lol [COLOR= #007700]() {

}[/COLOR]

[URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"lol"[/COLOR][COLOR= #007700].[/COLOR]Lol[COLOR= #007700]();.[/COLOR][COLOR= #DD0000]"lol"[/COLOR][COLOR= #007700]);[/COLOR]
?>


toevoeging op 23 januari 2012, 17:41:09:
Ik zal het anders vragen. Dit script is onafgewerkt, en dit toont form waar elke field uit DB als input staat. Als je op toevoegen wil ik dat die die toevoegt. Ik mis alleen nog maar 1 stukje...

[COLOR= #0000BB]<?php[/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]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]submit[/COLOR][COLOR= #007700]])) {[/COLOR]


[URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"INSERT INTO "[/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]insert[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]" (WAT MOET HIER) VALUES (EN WAT MOET HIER?)"[/COLOR][COLOR= #007700]);
}[/COLOR]
?>
<form action="?insert=[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]insert[/COLOR][COLOR= #007700]];[/COLOR] ?>" method="post">
<table style="border: 0px; width: 100%;">
<tbody>[COLOR= #0000BB]<?php
$table[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]insert[/COLOR][COLOR= #007700]]);[/COLOR]
[COLOR= #0000BB]$dbname[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"wax_systeem"[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$fields[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_listfields"]mysql_listfields[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$dbname[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$table[/COLOR][COLOR= #007700]);[/COLOR]

[COLOR= #0000BB]$field_num[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_num_fields"]mysql_num_fields[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$fields[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$i[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #0000BB]0[/COLOR][COLOR= #007700];[/COLOR]

[URL="http://www.php.net/while"]while[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$i[/COLOR] [COLOR= #007700]<[/COLOR] [COLOR= #0000BB]$field_num[/COLOR][COLOR= #007700]) {[/COLOR]
        [COLOR= #0000BB]$name[/COLOR]  [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_field_name"]mysql_field_name[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$fields[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$i[/COLOR][COLOR= #007700]);[/COLOR]
?>
<tr>
<td>
<b>[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$name[/COLOR][COLOR= #007700];[/COLOR] ?>:</b>
</td>
<td style="width: 465px;">
<input type="input" name="input[COLOR= #0000BB]<?[/COLOR]php [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$name[/COLOR][COLOR= #007700];[/COLOR] ?>"[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$name[/COLOR] [COLOR= #007700]==[/COLOR] [COLOR= #DD0000]id[/COLOR][COLOR= #007700]) {[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]" style="width: 100px;""[/COLOR][COLOR= #007700]; }[/COLOR] ?>></input>
</td>
</tr>
[COLOR= #0000BB]<?php
    $i[/COLOR][COLOR= #007700]++;
}[/COLOR]
?>
<tr>
<td colspan="2" style="text-align: center;">
<input type="submit" value="Toevoegen" name="submit">
</td>
</tr>
</tbody>
</table>
</form>
0
Berichten
5.957
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Zeg gewoon wat je aan het maken bent, als je dat wil geheim houden ben je duidelijk fout bezig ...
0
Antonn

Lid · Topicstarter

Berichten
8.649
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ik maak hierciets dat je tabel kan selecteren, en dan in die tabel nieuwe row kan ilserten. Kijk naar de form, en dan naar de INSERT INTO. Ik weet niet hoe ik aan de insert into begin.
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
Kan je jouw databasestructuur even laten zien.
Ik heb mijn twijfels of je op de goede weg bezig bent.
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