[GastForen Programmierung/Entwicklung PHP und MySQL

  • Suche
  • Hilfe
  • Lesezeichen
  • Benutzerliste

Link in MySQL ausgabe - wie??

fightingfalcon
Beiträge gesamt: 14

14. Jul 2005, 18:54
Bewertung:

gelesen: 764

Beitrag als Lesezeichen
Hallo!

Also ich habe eine suchfunktion für meine sql db!

siehe http://www.fightingfalcon.net/searchdb.php

(gebt bei name mal "Luftfahrt" ein)

jetz meine frage:
wie mach ich es dass der name des gesuchten museums ein bestimmter link ist?

wenn der name des Museums z.B. "Luftfahrtmuseum Graz-Thalerhof" ist

soll der link "museen/Luftfahrtmuseum Graz-Thalerhof.php"

heißen

wie stell ich das an??

Hier mal der Code

Code
<? 
mysql_connect("localhost", "dbadmin007", "pw") or die(mysql_error());
mysql_select_db("db") or die(mysql_error());
// zu durchsuchende tabelle
$tabelle = "museum";
// spalten, nach denen man nicht suchen können soll
$hiddenrows = array('id', 'password');

$q_cols = mysql_query("show columns from `".$tabelle."`") or die("\n<r />zeile7:".mysql_error());


if(empty($_POST['search'])){
// formular

?></font>
<form method="post">
<font size="1" color="#cccccc" face="Verdana, Arial, Helvetica, sans-serif"><?
while($col = mysql_fetch_assoc($q_cols))
if(!in_array($row['Field'], $hiddenrows, true))
echo $col['Field'].': <input type="text" name="field['.$col['Field'].']"><br />'."\n";
?></font><input type="submit" name="search" value="suchen">
</form>
<font size="1" color="#cccccc" face="Verdana, Arial, Helvetica, sans-serif"><?
}
else{
$sql = 'select * from `'.$tabelle.'` where';
$i = 1;
foreach($_POST['field'] as $field => $val){
if(!empty($val))
$f[$field] = $val;
}
foreach($f as $field => $val){
if(!empty($val)){
$where .= " `".$field."` like '%".$val."%'";
if($i < count($f))
$where .= ' or';
}
$i++;
}
if(empty($where))
echo 'keine suchbegriffe angegeben!';
else{
$sql .= $where;

$q_res = mysql_query($sql) or die("\n<r />zeile43:".mysql_error());
?>
</font>
<table width="580" cellpadding="2" cellspacing="1" style="background-color: #333333; color: #cccccc; font-size: 10px; font-family: Verdana" border="0">
<tr style="background-color: #808080;"><?
while($col = mysql_fetch_assoc($q_cols))
if(!in_array($row['Field'], $hiddenrows, true))
echo "<b><td style=\"background-color: #808080; color:#000000;\">".$col['Field']."</td></b>\n";
?></tr>
<?
while($row = mysql_fetch_assoc($q_res)){
echo "<tr style=\"background-color: #2f4f4f;color:#cccccc;\">\n";
foreach($row as $field)
echo "<td>".$field."</td>\n";
echo "</tr>\n";
}
?>
</table>
<font size="1" color="#cccccc" face="Verdana, Arial, Helvetica, sans-serif"><?
}
}
?>


(Dieser Beitrag wurde von fightingfalcon am 14. Jul 2005, 18:56 geändert)
Änderungsverlauf:
Beitrag geändert von fightingfalcon (Novice) am 14. Jul 2005, 18:56