WCM Forum

WCM Forum (http://www.wcm.at/forum/index.php)
-   Programmierung (http://www.wcm.at/forum/forumdisplay.php?f=17)
-   -   php mysql frage (http://www.wcm.at/forum/showthread.php?t=57543)

James 24.05.2002 23:43

php mysql frage
 
also mal zur situation ich schicke im nem html formular daten zu ner mysql datenbank der text kommt in ein "blob" type feld

das funkt auch das is das gute hehe aber was ich jetzt wisse wollte ob es einen einfachen weg gibt die links ie: "http://www.xxx.com" als echten link auszugeben wenn man den datensatz von der datenbank holt?

so wie das auch in diesem board is

bev 25.05.2002 00:25

also wenn ich das richtig verstehe
 
dann holst du dir daten aus der db zb: "www.xxx.at" und dann willst an link draus machen ...

saug dir deine daten in eine variable und gib sie mit dem link
aus, zb:

print "das ist der link";


und ich glaub blob als datenfeld is a bissal groß für an link ;)
nimm char(100) oder so in dem bereich.

Gruß

James 25.05.2002 00:32

ops wieder ned alles geschrieben ie des eintrag is so

"hey das is a coole seite http://www.xxx.com/ <-- schauts euch das an"

und da dann an link draus machen

_m3 25.05.2002 09:56

Code:

<html>
<head>

<title>Test</title>
</head>

<body>
<?php
$t = "hey das is a coole seite http://www.xxx.com/ <-- schauts euch das an";

echo preg_replace( "/((www\.|http:\/\/).*?)\s/", "<a href=\"$1\" target=\"_new\">$1</a> ", $t) . "
\n";

$t = "hey das is a coole seite www.xxx.com <-- schauts euch das an";

echo preg_replace( "/((www\.|http:\/\/).*?)\s/", "<a href=\"$1\" target=\"_new\">$1</a> ", $t) . "
\n";

?>
</body>
</html>

Einzige Bedingung: Dei URL muss durch einen Blank, Tab, etc. an Ende vom Text getrennt sein.

James 25.05.2002 13:59

@_m3 !!! ich danke dir hehe funkt supergut

James 25.05.2002 14:23

ich hab noch was geändert

$t1 = preg_replace( "/((www\.|http:\/\/).*?)\s/", "<a href=\"http://$1\" target=\"_new\">$1</a> ", $t) . "
\n";
echo str_replace("http://http://","http://",$t1);

weil wenn "www.cool.at" hat er versucht http://meinhost/test/www.cool.at draus zu machen

jetzt tut er immer das http:// dazu und wenns doppelt is halt einmal wieder weg :hehe: is zwar irgendwie um an berg runderrum aber ich weiss nix anderes ;)


Alle Zeitangaben in WEZ +2. Es ist jetzt 22:33 Uhr.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
© 2009 FSL Verlag