Note that there are some explanatory texts on larger screens.

plurals
  1. PODisplay different row of a database upon clicking a button
    primarykey
    data
    text
    <p>I have a database of mosques with the following fields: mosque_id, mosque_name, prefecture, address, postal_code, website, email1, phone1 . What I want to do is to display the information of the first mosque (mosque_id=1) in a form and when I click "Next", the information of the second mosque (mosque_id=2) will be displayed.</p> <p>So far, I've been able to use mosque_id to select an entire row and display the information, but I've been struggling to find a way to switch to the next one. I'm very new to PHP and MYSQL, any help would be appreciated.</p> <pre><code>&lt;? $mosque_id = 1; $result = mysql_query("SELECT * FROM Mosque WHERE mosque_id='$mosque_id'"); $row = mysql_fetch_assoc($result); ?&gt; &lt;form action="insert.php" method="post"&gt; Mosque Name: &lt;?php print('&lt;input type="text" name="firstname" value="' . $row['mosque_name'] . '"/&gt;&lt;br&gt;')?&gt; Prefecture: &lt;?php print('&lt;input type="text" name="firstname" value="' . $row['prefecture'] . '"/&gt;&lt;br&gt;')?&gt; Address: &lt;?php print('&lt;input type="text" value="' . $row['address'] . '"/&gt;&lt;br&gt;')?&gt; Postal Code: &lt;?php print('&lt;input type="text" value="' . $row['postal_code'] . '"/&gt;&lt;br&gt;')?&gt; Website: &lt;?php print('&lt;input type="text" value="' . $row['website'] . '"/&gt;&lt;br&gt;')?&gt; Email 1: &lt;?php print('&lt;input type="text" value="' . $row['email1'] . '"/&gt;&lt;br&gt;')?&gt; Contact number 1: &lt;?php print('&lt;input type="text" value="' . $row['phone1'] . '"/&gt;&lt;br&gt;')?&gt; &lt;input type="button" value="Next Mosque" onclick=""/&gt; &lt;/form&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    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