Kolom in database aanpassen

Gestart doorVince5 reacties55 weergaven

6 berichten · pagina 1 van 1

Vince

Lid · Topicstarter

Berichten
1.028
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ik wil in mijn database een hele kolom aanpassen. De kolom heet links en in iedere rij staat een link bv:

1. http://google.nl
2. http://one2xs.com
3. http://google.com

Nu wil ik alle rijen aanpassen en achter de link een woord zetten, bijvoorbeeld /home. Zodat het dan:

1. http://google.nl/home
2. http://one2xs.com/home
3. http://google.com/home

word. Ik heb alleen geen zin om ze een voor een aan te moeten passen. yummie Kwam er zelf even niet uit.

Kan iemand even een query schrijven? smile
0
Berichten
747
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
selecteer links, while loop, update
Moet wel lukken toch?
0
Vince

Lid · Topicstarter

Berichten
1.028
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?php
        $top2[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"SELECT link FROM `producten`"[/COLOR][COLOR= #007700];[/COLOR]
        [COLOR= #0000BB]$top1[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$top2[/COLOR][COLOR= #007700]);[/COLOR]
        [URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$top[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$top1[/COLOR][COLOR= #007700]))
        {[/COLOR]
        [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]UPDATE `producten` set link = "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$top[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]link[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]blabla"[/COLOR][COLOR= #007700]);
        }[/COLOR]
        ?>


Daarmee update die alles naar de eerste link. Niet allemaal appart dus.
0
Berichten
3.461
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Je moet ook nog een WHERE clauss toevoegen.smile
0
Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"UPDATE producten SET link = link+/home"[/COLOR][COLOR= #007700]);[/COLOR] ?>
0
Vince

Lid · Topicstarter

Berichten
1.028
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Het is al gelukt.
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