NameSilo

Mysql to list script

SpaceshipSpaceship
SpaceshipSpaceship
Namecheap AuctionsNamecheap Auctions
Watch

ctechguy

Established Member
Impact
0
I'm trying to make an add your own link, but i want an admin verify. Does anybody now how to take information from a mysql data base and put it in to a list.

PHP:
<form id="form1" name="form1" method="post" action="">
  <label>
  <select name="select" size="5">
    <option>data from mysql</option>
    <option>http://www.webdesigntalk.net</option>
    <option>http://www.google.com</option>
  </select>
  </label>
</form>
 
0
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
It depends on your database structure but you could use something like the code below. This is assuming you have a DB structure like:

TABLE NAME :: links

id.|.url..............................|.active
--+------------------------+-------
1..|http://www.google.com..| 1
2..|http://www.yahoo.com..| 1
3..|http://www.msn.com.....| 0

PHP:
// Setup Database Handle
$conn = mysql_connect ('localhost' , $dbUser , $dbPass);
$db    = mysql_select_db ($dbName , $conn);

// Get links
$sql    = "SELECT * FROM links WHERE active = '1'";
$result = mysql_query ($sql , $conn);

// Print top part of code
print <<<HERE

 <form id="form1" name="form1" method="post" action="">
  <label>
    <select name="select" size="5"> 

HERE;

// For each link
while ($link = mysql_fetch_assoc ($result)){
  $url = $link['url'];

  print "<option>$url</option>\n";
}

// Print bottom half of code
print <<<HERE

    </select>
  </label>
</form>  

HERE;

My PHP isn't that great but I think that should work.

Tell me if you need any other help :)


Hodge
 
0
Close
Moved to programming.
 
0
Close
Appraise.net

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

Each character of a domain name in its own box, with how to type one of them
Bookmarks: see bookmarks without a label
You can now show only the bookmarks you have not labeled. Open the label filter in the Bookmarks tab of your account menu, or on your...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back