Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <ol> <li><p><strong>Your code is vulnerable to SQL injection.</strong> You <em>really</em> should be using <a href="https://stackoverflow.com/a/60496/623041">prepared statements</a>, into which you pass your variables as parameters that do not get evaluated for SQL. If you don't know what I'm talking about, or how to fix it, read the story of <a href="https://stackoverflow.com/questions/332365/xkcd-sql-injection-please-explain">Bobby Tables</a>.</p></li> <li><p>Please stop writing new code with the ancient MySQL extension: it is no longer maintained and the community has begun the <a href="http://news.php.net/php.internals/53799" rel="nofollow noreferrer">deprecation process</a>. Instead you should use either the improved <a href="http://php.net/mysqli" rel="nofollow noreferrer">MySQLi</a> extension or the <a href="http://php.net/pdo" rel="nofollow noreferrer">PDO</a> abstraction layer.</p></li> <li><p>Learn about <a href="http://www.codinghorror.com/blog/2007/10/a-visual-explanation-of-sql-joins.html" rel="nofollow noreferrer">SQL joins</a>.</p></li> <li><p>You <em>really</em> should endeavour to change your schema to have either:</p> <ul> <li><p>a destination foreign key in the hotels table (if a hotel is associated with no more than one destination); or</p> <pre class="lang-sql prettyprint-override"><code>ALTER TABLE sirev_Hotels ADD COLUMN hoDestination INT, ADD FOREIGN KEY hoDestination REFERENCES sirev_Dests (deDestCode) </code></pre></li> <li><p>a table of destination-hotel relations (if a hotel can be associated with multiple destinations).</p> <pre class="lang-sql prettyprint-override"><code>CREATE TABLE sirev_DestinationHotels ( dehoDestination INT, dehoHotel INT, FOREIGN KEY dehoDestination REFERENCES sirev_Dests (deDestCode), FOREIGN KEY dehoHotel REFERENCES sirev_Hotels (hoCode) ) </code></pre></li> </ul></li> <li><p>If that is not possible, you can use MySQL's <a href="http://dev.mysql.com/doc/en/string-functions.html#function_find-in-set" rel="nofollow noreferrer"><code>FIND_IN_SET()</code></a> function as a join criterion:</p> <pre class="lang-sql prettyprint-override"><code>SELECT hoCode, hoName FROM sirev_Hotels JOIN sirev_Dests ON FIND_IN_SET(sirev_Hotels.hoCode, sirev_Dests.deHotels) WHERE sirev_Dests.deDestName = ? </code></pre></li> <li><p>Having joined the tables and obtained the <code>hoCode</code> and <code>hoName</code> of all hotels in your desired destination, you can loop over the resultset outputting <code>&lt;option value="$hoCode"&gt;$hoName&lt;/option&gt;</code>, applying <a href="http://php.net/manual/en/function.htmlentities.php" rel="nofollow noreferrer"><code>htmlentities()</code></a> as appropriate.</p></li> </ol>
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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