pbahmann1 pbahmann1 - 19 days ago 7
PHP Question

fetch first column from table

First of all thanks for reading this.


I'm having this function setup

function SelectHydross($conn){
$sql = "SELECT * from HydrossTheUnstable";
$data = $conn->query($sql);

$title = $data->fetchColumn(1);
echo '<div><table>';
echo '<tr>';
echo "<th>" . $title['BossName'] . "</th>";


Which gives me
Warning: Illegal string offset 'BossName'


Line 70 is:
echo "<th>" . $title['BossName'] . "</th>";





If i'm using this code


function SelectHydross($conn){
$sql = "SELECT * from HydrossTheUnstable";
$data = $conn->query($sql);
$title = $data->fetch(PDO::FETCH_ASSOC);
echo '<div><table>';
echo '<tr>';
echo "<th>" . $title['BossName'] . "</th>";


It does skip the first column and starts with the 2nd.

I don't know any way out at the moment and i'd like to ask for some help!

This is how my table looks like

enter image description here

Answer

As I outlined in comments which I won't repeat (you can read those), you can use LIMIT with an offset that can skip a row.

I.e.: LIMIT 1,10 in a SELECT statement.

The manual:

Example:

[LIMIT {[offset,] row_count | row_count OFFSET offset}]
Comments