Jump to content

echo help, include java string


herghost

Recommended Posts

Thanks,

 

I also would like to know how to display more than one row from my database, this is the query I have, but it only shows the 1st row, how would I make it show all rows?

 

 

<?php		$query = mysql_query("SELECT * FROM cats WHERE level='1' LIMIT 2");		if (!$query) {    echo "Could not run query: " . mysql_error();    exit;}		$row = mysql_fetch_row($query);		{			echo "<li><a href=\"javascript:ajaxpage('" . $row[1] . ".php', 'content');\">" . $row[1] . "</a></li>";		}		?>

 

Sorry to be blunt, but every php/mysql book or basic php/mysql tutorial shows how to retrieve multiple rows from a query. You are asking something that is very basic, so it would seem that you have not bothered to learn the basic information that you need to know before you are attempting to do this with your data. (Before you can write a book, you must know how to write at all.)

 

If you take the time to learn some of the basic php/mysql programming information, you can produce working code at least 10 times faster than if you just try things you might have seen without knowing what they mean or what each line of code actually does.

 

A basic php/mysql tutorial that executes a query and iterates over all the rows that it returns -

http://w3schools.com/php/php_mysql_select.asp

Thans to both, I will do some further reading, I just like the learn as you go approach, once I can see something working I can then replicate it and learn as I go, I did have a read about, but I was looking at foreach and I could not find an example which took results from a database

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.