Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

db record as drop down menu selection

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

db record as drop down menu selection

Postby npereira » Wed Jan 15, 2003 6:14 pm

How can I do this?

Here is my code;

This part is to delete a link in the db, but you need to know the name of it (It would be better if you could choose from a list that is in the db);
Code: Select all
<?

include "inc/loader.php";

?>

<HTML>
<BODY>

<form method="post" action="dellink.php" name="editor">
  <div align="center"><center><table width="600" border="0" cellspacing="0" cellpadding="1"
  bgcolor="#000000" align="center">
    <tr>
      <font size="2" face="Verdana" color="#ff0000" , Arial, Helvetica, sans-serif"><b>Delete External Link</b></font><td><div
      align="center"><center><table width="598" border="0" cellspacing="0" cellpadding="1">
        <tr>
          <td bgcolor="#CCCCCC"><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><b>Button Name</b>: <b>
              <input type="text" name="linkbutton" size="50">
              </b></font></td>
        </tr>
      </table>
      </td>
    </tr>
  </table>
  </center></div>
<br>
<div align="center"><center><table width="600" border="0" cellspacing="0"
  cellpadding="1" bgcolor="#000000" align="center">
    <tr>
      <td><table width="598" border="0" cellspacing="0" cellpadding="1">
        <tr>
          <td bgcolor="#CCCCCC"><div align="center"><p><input TYPE="SUBMIT" NAME="submit"
          VALUE="Delete External Link"></td>
        </tr>
      </table>
      </td>
    </tr>
  </table>
  </center></div>
</form>
</body>


this is the file the form above POST to, to delete the record;
Code: Select all
<?

include "inc/loader.php";


        $query = "DELETE FROM ".DB_PREFIX."_link WHERE link_button = '$linkbutton' ";
        mysql_query($query);
   echo mysql_error($connexion);
       
   $body=stripslashes($body);
   $title=stripslashes($title);
   
        header("Location: editor.php");
   
?>
[quote]

Regards,

NPereira[/quote]
npereira
New php-forum User
New php-forum User
 
Posts: 10
Joined: Wed Jan 15, 2003 4:01 pm

Postby Redcircle » Wed Jan 22, 2003 12:40 am

Code: Select all
$query = 'select * from table';
$result = mysql_query($query)

echo '<select name="form_list">';
while($row=mysql_fetch_array($result))
{
echo '<option value="'.$row['value'].'">'.$row['name'].'</option>';

}
echo '</select>';



what this code does is query the database and puts the results into a select box. I think this is what you wanted. not 100% sure tho.
User avatar
Redcircle
Moderator
Moderator
 
Posts: 830
Joined: Tue Jan 21, 2003 10:42 pm
Location: Michigan USA


Return to PHP coding => General

Who is online

Users browsing this forum: Google [Bot] and 5 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron