Note that there are some explanatory texts on larger screens.

plurals
  1. POMySQL -> Dropdown and back
    primarykey
    data
    text
    <p>I just started my 'journey' with this kind of programming and I've got a problem. I was searching for similar issues but haven't found satisfactory answer here. So, here it comes: What I'm trying to do is to load some data from database to my <code>dropdown</code> menu on <code>html</code> page. I managed to did it this way:</p> <pre><code>&lt;?php session_start(); if(!(isset($_SESSION['loggedIn']) || $_SESSION['loggedIn'] == true)) { header("location:index.php"); exit(); } include 'connection.php'; include 'func.php'; $arajka=getRdyDev(); ?&gt; &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;body&gt; &lt;p&gt; blablabla &lt;br/&gt; &lt;/p&gt; &lt;select&gt; &lt;? foreach ($arajka as $a) { echo "&lt;option value=\"" .$a['id']. "\"&gt;" .$a['id']. "_" . $a['name'] . "&lt;/option&gt;"; } ?&gt; &lt;/select&gt; &lt;p&gt; &lt;br/&gt;blablabla&lt;/p&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Well, looks like a spaghetti to me, but w/e, that's my first <code>PHP</code> code ever. In my database I've got columns called <code>ID</code> <code>NAME</code>, <code>LAT</code>, <code>LON</code>, <code>BUSY</code>. In <code>getRdyDev()</code> I return array of devices that are not busy at the moment. In <code>&lt;select&gt;</code> I print only <code>ID</code> and <code>NAME</code>. Now I want to get <code>LAT</code> and <code>LON</code> when user clicks on specific <code>&lt;option&gt;</code> and I've got no idea how to do this. (I don't want to reload whole page but only, I don't know, <code>&lt;div&gt;</code> with some <code>textfields</code> maybe?). In the next step I will use that data (to be exact: <code>id</code>) to insert some other data to other table in my database. Any suggestions please?</p> <p>Kind regards!</p>
    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