Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing fopen and str_replace to auto fill a select option
    primarykey
    data
    text
    <p>I have this file <strong>'gardens.php'</strong>, which pulls data from a table called <strong>'generalinfo'</strong> and I use fopen to send that data to a file called <strong>'index.html'</strong>. Here is the issue, only one option is filled. I have a demo running here <a href="http://gardening.andcreate.com/gardens.php" rel="nofollow noreferrer">Garden Demo</a> <strong>&lt;-- this is a new updated page and location, there are more errors than I have locally If anyone could help me fix them</strong> Username:stack1 Password:stack1</p> <p>Is there a better way to achieve what I want to?</p> <p>Thanks! Always.</p> <p><strong>GARDENS.PHP</strong></p> <pre><code>&lt;?php include("connect.php"); $results = mysql_query("SELECT * FROM generalinfo"); while($row = mysql_fetch_array($results)){ $country = $row['country']; $province = $row['province']; $city = $row['city']; $address = $row['address']; //echo $country; //echo $province; //echo $city; //echo $address; } $fd = fopen("index.html","r") or die ("Can not fopen the file"); while ($buf =fgets($fd, 1024)){ $template .= $buf; } $template = str_replace("&lt;%country%&gt;",$country,$template); echo $template; ?&gt; </code></pre> <p><strong>INDEX.PHP SNIPPET</strong></p> <pre><code>&lt;form name="filter" method="get" action="filter.php"&gt; &lt;select class="country" name="country"&gt; &lt;option&gt;&lt;%country%&gt;&lt;/option&gt; &lt;/select&gt; &lt;/form&gt; </code></pre> <p><strong>CONNECT.PHP</strong></p> <pre><code>&lt;?php mysql_connect("mysql.andcreate.com", "*******", "********")or die("Cannot Connect to DB"); mysql_select_db("gardencollective")or die("cannot select the DB table"); mysql_close(); ?&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