Forum Moderators: coopster
<?php
$dbh=mysql_connect("localhost", "my_username", "my_password") or die ('No can do!');
mysql_select_db ("my_databasename");
$query = "SELECT * FROM contacts";
while($i = mysql_fetch_array($query)){
echo $i[first];
echo $i[last];
echo $i[email];
}
?>
Get this error message:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home2/my_username/my_domain/my_databasename/test.php on line 6
what am I doing wrong?
You missed one crucial function in your script...mysql_query() [php.net].
You will need to add that function just before the while() loop.
$query = "SELECT * FROM contacts";
$result = mysql_query($query);
while($i = mysql_fetch_array($result)){
I fixed the problem. My database output is working just great.
However, I cant get around one problem: there are about 2600 rows in my database - all get sent to the output as a continous table. How do I make the output say 30 rows and then a button/link to display the next 30 and so on...
To calculate the no. of pages just divide the total number of rows in the table by 30. If you get returned a fraction, "round-up" i.e. if you get 50.12, no. of pages become 51.
previous_page = current_page - 1 (unless current_page is one)
next_page = current_page + 1 (unless current_page is last page)
Just some pointers ;-)
Saurabh.