I often use:
mysql_num_rows returns the number of rows anyways.Code:$query = "SELECT * FROM table"; $result = mysql_query($query); $num = mysql_num_rows($result); for ($i = 0;$i < $num;$i++) $fields = mysql_result($result,$i,"myfield");
I often use:
mysql_num_rows returns the number of rows anyways.Code:$query = "SELECT * FROM table"; $result = mysql_query($query); $num = mysql_num_rows($result); for ($i = 0;$i < $num;$i++) $fields = mysql_result($result,$i,"myfield");
- Mike
Haha, whoops -- I think it should have beenI didn't really look, just inserted code around what was already thereCode:for($resultnumber = 1; $iddrow = mysql_fetch_array($iddrs); ++$resultnumber)![]()
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
So calling the array directly will give you it's length?
- Mike
twey, is that not the same code you posted before?!![]()
I didnt know where to put it, so i tried before, then after the while statement.. but both just show 1 as the result..
Like this:Code:<?php $iddaddress = "localhost"; $iddusername = "xxxx"; $iddpassword = "xxxx"; $idddb = "xxxx"; $iddconn = mysql_connect($iddaddress, $iddusername, $iddpassword); $iddrs = mysql_select_db($idddb, $iddconn); $iddsql="SELECT * FROM handset GROUP BY handset"; $iddrs = mysql_query($iddsql, $iddconn); for($resultnumber = 1; $iddrow = mysql_fetch_array($iddrs); ++$resultnumber) { $iddmake = $iddrow['make']; $iddhand = $iddrow['handset']; $idddetails = $iddrow['details']; echo("This is result number: $resultnumber"); } mysql_close(); ?>
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
thanks twey and everyone else!! works great!
Bookmarks