PHP script to import URL and text from database

Discussion in 'PHP' started by Darwyn, Jun 16, 2010.

  1. #1
    Hello,

    I've done some research the last couple days and haven't been able to get anything to work...

    What I need is a PHP script to display a list of venue names [venueName] and link them to the URL [venueMap] stored in a database. I can connect to the database and list the 'venueName' but cannot figure out how to associate that with the URL stored in the 'venueMap' column.

    Any help?
     
    Darwyn, Jun 16, 2010 IP
  2. stephan2307

    stephan2307 Well-Known Member

    Messages:
    1,277
    Likes Received:
    33
    Best Answers:
    7
    Trophy Points:
    150
    #2
    What code do you have so far?
     
    stephan2307, Jun 16, 2010 IP
  3. Darwyn

    Darwyn Peon

    Messages:
    34
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    after some research and some manipulation, I'm left with...

    <table width="600" border="0" cellspacing="2" cellpadding="2">
    		  <tr>
    		    <td><?php do { ?>
    		        <?php echo <a href= . $row_Venue_set['venueMap'] . $row_Venue_set['venueName']</a>;  ?>
    		        </td>
    		    <td>&nbsp;</td>
    	      </tr>
    		  <tr>
    		    <td><?php } while ($row_Venue_set = mysql_fetch_assoc($Venue_set)); ?></td>
    		    <td>&nbsp;</td>
    	      </tr>
        </table>
    Code (markup):
     
    Darwyn, Jun 16, 2010 IP
  4. stephan2307

    stephan2307 Well-Known Member

    Messages:
    1,277
    Likes Received:
    33
    Best Answers:
    7
    Trophy Points:
    150
    #4
    can you show a bit more as that does not help much more. Also show the structure of the database.
     
    stephan2307, Jun 16, 2010 IP
  5. Darwyn

    Darwyn Peon

    Messages:
    34
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    well aside from the database connection script here's the php query:

    mysql_select_db($database_Venue, $Venue);
    $query_Venue_set = "SELECT venueName, venueMap FROM Venue ORDER BY venueName ASC";
    $Venue_set = mysql_query($query_Venue_set, $Venue) or die(mysql_error());
    $row_Venue_set = mysql_fetch_assoc($Venue_set);
    $totalRows_Venue_set = mysql_num_rows($Venue_set);
    PHP:
    I'm not quite sure what you mean by database structure. It's mysql with a table called Venue that contains 5 or 6 rows. Two of which are [venueName] and [venueMap]. the Name is simple text, the Map is a http:// URL. I need to import both of them, but only display the text (venueName) as a link.

    It should look like this:

    www.musl.net/venue_test.php Except this example isn't dynamic.
     
    Darwyn, Jun 16, 2010 IP
  6. stephan2307

    stephan2307 Well-Known Member

    Messages:
    1,277
    Likes Received:
    33
    Best Answers:
    7
    Trophy Points:
    150
    #6
    is this what you mean:
    
    <table width="600" border="0" cellspacing="2" cellpadding="2">
    		  <tr>
    		    <td><?php do { ?>
    		        <?php echo '<a href="'. $row_Venue_set['venueMap'] .'">'. $row_Venue_set['venueName'].'</a>';  ?>
    		        </td>
    		    <td>&nbsp;</td>
    	      </tr>
    		  <tr>
    		    <td><?php } while ($row_Venue_set = mysql_fetch_assoc($Venue_set)); ?></td>
    		    <td>&nbsp;</td>
    	      </tr>
        </table>
    
    PHP:
     
    stephan2307, Jun 16, 2010 IP
  7. Darwyn

    Darwyn Peon

    Messages:
    34
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Darwyn, Jun 16, 2010 IP
  8. stephan2307

    stephan2307 Well-Known Member

    Messages:
    1,277
    Likes Received:
    33
    Best Answers:
    7
    Trophy Points:
    150
    #8
    No problem.
     
    stephan2307, Jun 16, 2010 IP