Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First off, <a href="https://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php"><strong>Don't use <code>mysql_*</code> functions in new code</strong></a>. They are no longer maintained <a href="https://wiki.php.net/rfc/mysql_deprecation" rel="nofollow noreferrer">and are officially deprecated</a>. See the <a href="http://uk.php.net/manual/en/function.mysql-connect.php" rel="nofollow noreferrer"><strong>red box</strong></a>? Learn about <a href="http://en.wikipedia.org/wiki/Prepared_statement" rel="nofollow noreferrer"><em>prepared statements</em></a> instead, and use <a href="http://php.net/pdo" rel="nofollow noreferrer">PDO</a> or <a href="http://php.net/mysqli" rel="nofollow noreferrer">MySQLi</a> - <a href="http://php.net/manual/en/mysqlinfo.api.choosing.php" rel="nofollow noreferrer">this article</a> will help you decide which. If you choose PDO, <a href="http://wiki.hashphp.org/PDO_Tutorial_for_MySQL_Developers" rel="nofollow noreferrer">here is a good tutorial</a>.</p> <hr> <p>example code, hope it helps</p> <pre><code>&lt;?php $db_name = "db"; $connection = mysql_connect('localhost','root','') or die(mysql_error()); $db = mysql_select_db($db_name,$connection) or die(mysql_error()); $sql = "SELECT customer_name,id from customers ORDER BY customer_name desc"; $result = mysql_query($sql,$db) or die(mysql_error()); if(mysql_num_rows($result)&gt;=1){ $form = '&lt;form method="POST" action=""&gt; &lt;p&gt;Customer name:&lt;select size="1" name="customer"&gt;'; while ($row = mysql_fetch_array($result)) { $form .='&lt;option value="'.$row['id'].'"&gt;'.ucwords($row['customer_name']).'&lt;/option&gt;'; } $form .=' &lt;/select&gt;&lt;/p&gt;&lt;p&gt;&lt;input type="submit" value="Submit"&gt;&lt;/p&gt;&lt;/form&gt;'; } echo $form; ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload