Jump to content

Search the Community

Showing results for tags 'drop-down list'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 1 result

  1. I built a simple input drop-down list, using <select> which populates from a mysql database. It works fine, but if the result from the query is not found then the drop-down list just shrinks and doesn't say anything. I want it to say something like: "Name not found". I've searched everywhere but I can't seem to find the way. This is my code: <?php if ( $myquery = $mysqli->prepare("SELECT name, idname FROM db WHERE name LIKE '%".$name."%'") ) { $myquery->execute(); $myquery->store_result(); $myquery->bind_result( $nompac, $idpac ) ; } <form name="form1" method="post" action="example.php"> <table > <tr> <td>Name: </td> <td> <select name="chosen_name"> <?php while ( $myquery->fetch() ) { echo "<strong><option value=".$idpac.">".$nompac."</option></strong>"; } ?> </select> </td> <td><input type="submit" name="Submit" value="Go" class="button"/></td> </tr> </table> </form> So I added: if ( empty( $myquery ) ) { echo "<strong><option value=''>Name not found</option></strong>"; } else { while ( $myquery->fetch() ) { echo "<strong><option value='".$idpac."'>".$nompac."</option></strong>"; } } But it just ignores the code and does nothing. Next I added var_dump($myquery); before the if( empty( $myquery ) ) and nothing happened, so I placed it next to the mysqli prepared query and the output was: Any ideas what am I doing wrong?
×
×
  • 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.