Jump to content

$sql="select * from mytable "


rabmerab

Recommended Posts

Hi every one, :)

 

May be this is a just a basic but I am stuck.

 

I am using the sql query  $sql="select * from mytable " to try to display 4 rows but I getting  only one.

when I am using mysql command line with the same query I get all the 4 rows.

the problem only in php.

The other things like connecting to mysql and selecting the database been done.

Any help please.

Thanks in advance.

 

Rabmerab :)

 

Screen shot:

 

#connect to my sql

$conn=@mysql_connect("localhost","me","mypass") or die ("Couldn't connect");

 

 

# select database

$rs=@mysql_select_db("mydatabase",$conn)or die("could not  select database");

 

 

#Create the sql query

 

$sql="select * from mytable ";

       

# Execute query

 

$rs= mysql_query($sql,$conn);

 

 

#get the number of rows

    $num=mysql_numrows($rs);

   

    while($row= Mysql_fetch_array($rs) )

    {

    $list="<br>".$row["imei"];

  echo($list);

    }

 

?>

 

 

 

 

Link to comment
Share on other sites

Hi there,

 

Thanks for replaying.

Is not that the problem;  in the program above, using $num=mysql_numrows($rs) to count number of rows should deliver 4, even if I add more rows always  echo($num) only show 1.

Any more ideas.

 

rabmerab

 

 

Link to comment
Share on other sites

Hi again,

 

I don't know how come it didn't display the error even i got display_errors in phpinfo shows it is on.

It did shows me other errors.

Any way even I change it to $num=mysql_num_rows($rs), now it shows 2 but in reality, the table has 6 rows.

I don't know what's going on. >:(

 

thanks for any more help.

 

rabmerab

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.