SELECT a specific value
Posted: Tue Feb 08, 2011 3:32 pm
I just started using mysql.
I manage to connect to the database just fine, but i got a problem getting a column.
First i ran the following sql statement to get my table.
Then in my php file i try to retive My Text
I manged to get the value using
However, accoring to me this would print notloggedin text twice, if i was to add another column.
So no matter what, it's a bad and ugly soluion.
This gives
If it would been an array, i figuer it would be like this
bytin(
notloggedin = "My Text",
)
Beacuse then i would just need to get the value of the notlogged in key. That is what i'm trying to accaomplis here.
Hope i made some sense on what i want.
I manage to connect to the database just fine, but i got a problem getting a column.
First i ran the following sql statement to get my table.
Code: Select all
CREATE TABLE bytin(
notloggedin TEXT NOT NULL);
INSERT INTO (notloggedin) values ("My Text")
I manged to get the value using
Code: Select all
Not logged in...<br/>
<?php
$sql = "SELECT * FROM bytin";
$result = mysql_query($sql);
print($result . '<br/>');
while($line = mysql_fetch_array($result)) {
print($line['notloggedin']);
}
So no matter what, it's a bad and ugly soluion.
This gives
Code: Select all
Not logged in...
Resource id #369
My Text
bytin(
notloggedin = "My Text",
)
Beacuse then i would just need to get the value of the notlogged in key. That is what i'm trying to accaomplis here.
Hope i made some sense on what i want.