simple db help for php row
Moderator: General Moderators
simple db help for php row
sorry...i've been stuck with duties dealing with a php/mysql setup...but i have not knowledge of these things...well, not much...
what i need to do is very simple...
with a link such as http://www.??????.com/webpage.php?id=2 or 3 or whatever...
i just need the page to return the correct row of information and insert it into the page...that's it...but i'm clueless...
i have connected to the database though...and can extract info from the db...but, only from the first record...i can't get other rows of information?
i've been searching all day...can anybody help?
thanks...jv
what i need to do is very simple...
with a link such as http://www.??????.com/webpage.php?id=2 or 3 or whatever...
i just need the page to return the correct row of information and insert it into the page...that's it...but i'm clueless...
i have connected to the database though...and can extract info from the db...but, only from the first record...i can't get other rows of information?
i've been searching all day...can anybody help?
thanks...jv
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
Code: Select all
$sql = SELECT * FROM yourTable WHERE id = ".$_GETїid]Code: Select all
$temp = mysql_query($sql);
while($result = mysql_fetch_array($temp))
ї
echo $resultїCOLUMN NAME];
echo $resultїCOLUMN NAME2];
]hi!
looks like this...sequence is acting as ID (i didn't set that up)...
thanks mucho for any input...jv
<?
mysql_connect("localhost"," "," ");
mysql_select_db("reviews");
$query = mysql_query("SELECT * FROM review where sequence='$sequence' " ) or die ("Unexpected error for MySQL database [1b]");
$row = mysql_fetch_array($query);
?>
looks like this...sequence is acting as ID (i didn't set that up)...
thanks mucho for any input...jv
<?
mysql_connect("localhost"," "," ");
mysql_select_db("reviews");
$query = mysql_query("SELECT * FROM review where sequence='$sequence' " ) or die ("Unexpected error for MySQL database [1b]");
$row = mysql_fetch_array($query);
?>
Nothing wrong with that just put in the WHILE part
while($row=mysql_fetch_array($query)){
print "My first column is ".$row[COLUMN_NAME_HERE];
...
}
On another point the die statement after your SQL is probably not much use unless you have completely screwed up the SQL syntax, which you haven't or the table gets deleted, so it will never be called. It is probably better to place it at the connect statement.
while($row=mysql_fetch_array($query)){
print "My first column is ".$row[COLUMN_NAME_HERE];
...
}
On another point the die statement after your SQL is probably not much use unless you have completely screwed up the SQL syntax, which you haven't or the table gets deleted, so it will never be called. It is probably better to place it at the connect statement.
column name?
why would i want column information...
i want one record...one row of information...
maybe i explained it wrong...probably...
i know it's not the best...it's working...so far...
thanks...jv
i want one record...one row of information...
maybe i explained it wrong...probably...
i know it's not the best...it's working...so far...
thanks...jv
Re: column name?
The print "My first column is ".$row[COLUMN_NAME_HERE]; was an example, sorry did you want us to write the whole thing for you, give me a couple of weeks and wait by your email.vaska wrote:why would i want column information...
i want one record...one row of information...
maybe i explained it wrong...probably...
i know it's not the best...it's working...so far...
thanks...jv