Note that there are some explanatory texts on larger screens.

plurals
  1. POSelecting a Column from a Row from a previous Query
    text
    copied!<p>I'm really sorry if this is a simple fix but I'm completely stumped, probably suffering from a temporary block.</p> <p>Anyway, my predicament goes like this, my website has a page that includes events, I, of course, have an events table which has the following fields:</p> <pre><code> EventID EventName EventStart EventEnd EventDesc </code></pre> <p>Now my first query, is to make sure I collect all events that haven't ended yet. Make sense?</p> <p>I am then doing a <code>for</code> which looks like this: <code>for($i=0;$i&lt;$numr;$i++)</code> - $numr is defined as - <code>$numr = mysqli_num_rows($sql)</code> and you can guess what $sql is? Just to be safe: <code>$sql = mysqli_query($link, "SELECT * FROM events WHERE EventEnd &gt;= NOW()")</code></p> <p>Inside this <code>for</code> loop, I intend to create multiple <code>&lt;option&gt;</code> tags for however many events there are. So far so good, it looks like this: <code>echo "&lt;option id='" . $i . "' name='" . $i . "' value='" . $i . "'&gt;</code></p> <p>That's where my problem is, I know need to get the <code>EventName</code> of the FIRST row that was returned from the sql query. I am unsure of how to do this? My initially thought was to use an array and store the names there, however, I am not 100% familiar with arrays in php.</p> <p>Is there a way you guys can help me out here? Again I'm really sorry if this is just a basic function I need to use or something but I'm having real problems right now.</p> <p>Thanks so much guys! Mike.</p>
 

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