PHP/MySQL

anuj_web

New Member
Messages
145
Reaction score
0
Points
0
hI

Is there something wrong with the code

$result = @mysql_query("SELECT * FROM dc WHERE DCID='$id'");
$pass1=mysql_result($result,"pass" );
$phone=mysql_result($result,"phone" );

Actually i want to fetcha row from the database and take data from that row ....

this is not working...
 

anuj_web

New Member
Messages
145
Reaction score
0
Points
0
can u please explain the code...its just goin' o'er my head

while ($row = mysql_fetch_assoc($result)) {
print "Row $rowcount<br />";

while(list($var, $val) = each($row)) {
print "<B>$var</B>: $val<br />";
}

print "<br />";
++$rowcount;
 

LHVWB

New Member
Messages
1,308
Reaction score
0
Points
0
Here's a better example for what you need. :)

PHP:
$result = mysql_query("SELECT * FROM dc WHERE DCID='$id'");

// Make sure that there is a result from the table
if ($result && mysql_num_rows($result))
{   
   //    Loop through all the results
    while ($row = mysql_fetch_assoc($result))
    {
        //    Store the information from the current row.
        $pass1=$row['pass'];
        $phone=$row['phone'];
    }
}
 

anuj_web

New Member
Messages
145
Reaction score
0
Points
0
I can understand this better,thanks

works beautifully ....

One more thing ..do i need to set variables back to null everytime i load the PHP file or it happens by its own..if yes then wat should i do
$var=0
or
$var=''
 
Last edited:

konekt

New Member
Messages
100
Reaction score
0
Points
0
I can understand this better,thanks

works beautifully ....

One more thing ..do i need to set variables back to null everytime i load the PHP file or it happens by its own..if yes then wat should i do
$var=0
or
$var=''
Every time a script is loaded all the variables are as they were when you first coded it (reset).
 
Top