Jump to content

show value from a mysql table selected


unistake

Recommended Posts

Hi all,

 

I am trying to make a members details section that can be updated.

 

I want to be able to "SELECT * FROM users WHERE email='$email'" and then show the values that can be changed in a html drop down box with the selection that was made when the user registered already selected="selected";

 

You will be able to see what I am attempting to do below.

 

<?php

$sql = "SELECT manufacturer FROM table1 WHERE email=$'email'";
$result = mysqli_query($cxn,$sql);
$row = mysqli_fetch_assoc($result);

foreach manufacturer in table1 { 
      if table1.manufacturer = table2.manufacturer {
               echo '<option name="manufacturer" selected="selected" value"$row['manufacturer']"</option>';
     }
     else {
              echo '<option name="manufacturer" value"$row['manufacturer']"</option>';
     }
}
?>

Link to comment
https://forums.phpfreaks.com/topic/218371-show-value-from-a-mysql-table-selected/
Share on other sites

put an html <form> tag around the options and when they press the submit button which you could label as "update" or something of that nature have it send them to a page you could save as update.php. in update.php run the sql statement of UPDATE to update your database, here is a tutorial on it.

 

http://www.w3schools.com/sql/sql_update.asp

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.