php.de

Zurück   php.de > Webentwicklung > Datenbanken

Datenbanken SQL und Co

Antwort
 
LinkBack Themen-Optionen Thema bewerten
Alt 03.11.2004, 07:56  
Gast
 
Beiträge: n/a
Standard English (sorry): Using MySQL record as URL in PHP?

Sorry for the English and posting on your board, guys, but I'm a bit desperate.

I have a database in which there's fields of event names and fields of URLs (all entered manually). I need an if/else statement that shows just the event name in a repeated region in a table ONLY if the URL field is NULL. Or else, it should show the event name and link to the URL listed in the corresponding URL field. Here's what I have, but it's not working. Any suggestions?

Info:
weddingEvent is the name given to this particular instance of the bound table. I used Dreamweaver, and it did the row_weddingEvent stuff on its own.
eventName is the name of the event and is a field in the table.
URL is the URL leading to a photo gallery of that event.

I need to get the URL to be used as a link with the text showing up as eventName in the php file when people look at it.


<?php if $row_weddingEvent['URL']=NULL ?><td><?php echo $row_weddingEvent['eventName']; ?></td>

<?php else ?><td><?php echo $row_weddingEvent['eventName']; ?></td>


Is this right? My page is showing up blank, but if I get rid of the if, else, and a href, it shows up fine (with a simple repeated region of weddingEvent['eventName'] by itself). A FULL HTML encoded page can be found here: http://www.dattiliostudio.com/phpExample.txt

-Galen
  Mit Zitat antworten
Sponsor Mitteilung
PHP Code Flüsterer

Registriert seit: 21.08.2005
Beiträge: 4682
PHP-Kenntnisse:
Fortgeschritten

Alt 03.11.2004, 09:33  
Erfahrener Benutzer
 
Registriert seit: 19.10.2004
Beiträge: 498
marsch
Standard

Hello,

this is nothing about MySql, actually, thus that post might be moved.
Nevertheless, that problem can be solved in several ways, the easiest is the PHP way (I guess):
PHP-Code:
# fetch results from database in an array as you alredy did
$result = ...;
# create the link or not
while (...) {
    if (
is_null ($row_weddingEvent['URL'])) {
        print (
sprintf ('<td>%s</td>'$row_weddingEvent['eventName']));
    } else {
        print (
sprintf ('<td>[url="%s"]%s[/url]</td>'$row_weddingEvent['URL'], $row_weddingEvent['eventName']));
    }

__________________
Cheers, Marco
marsch ist offline   Mit Zitat antworten
Alt 03.11.2004, 16:21  
Gast
 
Beiträge: n/a
Standard

How do I apply this to my HTML?
Here's what I have so far:

PHP-Code:
<tr>
  <td><?php echo $row_weddingEvent['date']; ?></td>
  <?php if (is_null ($row_weddingEvent['URL'])) {
    print (
sprintf ('<td>%s</td>'$row_weddingEvent['eventName']));
  } else {
    print (
sprintf ('<td>[url="%s"]%s[/url]</td>'$row_weddingEvent['URL'], $row_weddingEvent['eventName']));
  } 
?>
  <td><?php echo $row_weddingEvent['location']; ?></td>
  <td><?php echo $row_weddingEvent['type']; ?></td>
</tr>
It now prints the eventName, but not with the link (there was a URL assigned to it from the URL field), and just copying/pasting what you wrote didn't work. I've been looking through the PHP.net tutorials, but none of it really ties into what I'm trying to do: using a variable as a link.
  Mit Zitat antworten
Antwort


Themen-Optionen
Thema bewerten
Thema bewerten:

Forumregeln
Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are an
Gehe zu

Ähnliche Themen
Thema Autor Forum Antworten Letzter Beitrag
[Erledigt] MySQL - ERROR 1044 bei erstellen einer Datenbank _youngenterpriser_ Datenbanken 2 05.02.2008 17:56
Mysql Server Einstellunen Optimieren pchero Datenbanken 3 01.05.2007 19:50
Kein Zugriff über ODBC mit der IP-Adresse auf MySql DB Datenbanken 4 09.02.2006 11:04
[Erledigt] Mysql 4.1.x unter php 4.3.9 Datenbanken 3 15.11.2005 13:49
Schnittstelle zwischen PHP und MySQL klappt net !!! Datenbanken 16 16.10.2005 14:24
[Erledigt] not allowed to connect to this MySQL server PHP Tipps 2005-2 2 23.09.2005 18:34
mysql_result(): supplied argument is not a valid MySQL PHP Tipps 2005-2 4 25.08.2005 14:44
[Erledigt] MySQL Befehl für MySQL 4.0.24 Datenbanken 2 23.08.2005 17:35
Suche Tipps für Persormance-Steigerung (Geld für Nützliches) Beitragsarchiv 18 16.08.2005 10:57
MYSQL läuft nur wenn /tmp auf 777 Datenbanken 5 06.07.2005 08:38
mysql root passwort vergessen Datenbanken 1 29.05.2005 11:33
Access denied for user: '@localhost' / SYSTEM@localhost Datenbanken 0 10.11.2004 20:35
English (sorry): Using MySQL record as URL in PHP? PHP Tipps 2004 3 04.11.2004 08:52
js und ie erkennung me Beitragsarchiv 12 02.09.2004 17:18
[Erledigt] PHP5 &amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;a m p; MySQL Datenbanken 5 01.08.2004 05:47

Besucher kamen über folgende Suchanfragen bei Google auf diese Seite
mysql event_name

Alle Zeitangaben in WEZ +2. Es ist jetzt 01:32 Uhr.




Powered by vBulletin® Version 3.7.2 (Deutsch)
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
Aprilia-Forum, Aquaristik-Forum, Liebeskummer-Forum, Zierfisch-Forum, Geizkragen-Forum

Creative Commons License
Dieser Inhalt ist unter einer Creative Commons-Lizenz lizenziert.