Ankündigung

Einklappen
Keine Ankündigung bisher.

English (sorry): Using MySQL record as URL in PHP?

Einklappen

Neue Werbung 2019

Einklappen
X
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • Gast-Avatar
    Ein Gast erstellte das Thema English (sorry): Using MySQL record as URL in PHP?.

    English (sorry): Using MySQL record as URL in PHP?

    Sorry, 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

  • marsch
    antwortet
    If it prints only the eventName, the URL is NULL. Did you spell URL correctly, or shouldn't it be named url instead? I cannot guess how your query looks like and what you are doing with your result set, as nobody can. There is too litlle information at all.

    Einen Kommentar schreiben:


  • Gast-Avatar
    Ein Gast antwortete
    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.

    Einen Kommentar schreiben:


  • marsch
    antwortet
    as I already told you...

    Einen Kommentar schreiben:

Lädt...
X