Php mysql array question?

Marco

New member
PS: as long as the requested result is there, I do not really care if you flip the code all over.
$allcats[0] = '';//variable array for storing the title of the movies retrieved from database.
function getallcats()
{
global $allcats;
$link_vid = mysql_connect(DB_HOST,DB_USER,DB_PASSWORD) or die("Couldn't make connection to database.");
$db_vid = mysql_select_db(DB_NAME, $link_vid) or die(mysql_error());
$retrievedinfo = mysql_query("select * from video_categories");
$num=mysql_numrows($retrievedinfo);
global $numcats;
$numcats = $num;
$i=0;
$ii=0;
while ($i < $num) {
$ii = (i + 1);
$allcats[$ii]=mysql_result($retrievedinfo,$i,"catname");
$i++;
}
return 1;
}

this is my code for getting the list: //second code:

getallcats();

for($i=1;$i < ($numcats + 1);$i++)
{
if(strlen($allcats[$i]) > 0)echo '<Option title=" ' . $allcats[$i] . '" Value="' . $allcats[$i] . '">' . $allcats[$i] .'</option>';
}

I noticed before yahoo answers screws up spaces and such, so i placed everything without indenting here.

Ok here is the goal: I need to get all available record values in a certain field. ( which works! )
However, while doing the second code ( printing all variables ), it only prints the last retrieved record.


CREATE TABLE IF NOT EXISTS `video_categories` ( // just extra information in case u would like to see it.
`catid` bigint(20) NOT NULL,
`catname` varchar(200) NOT NULL,
`Parentcat` varchar(200) NOT NULL COMMENT 'if parent category is set, this is a subcategory',
`VidIDs` text NOT NULL COMMENT 'stores the Id''s seperated by comma ,',
`creationdate` varchar(12) NOT NULL default '00/00/0000'
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

I want that the listing of the video titles, starts in array number 1, so number zero is unused.
It must loop till all names are retrieved.
Redirect links to somehow or supposed helpfull sites are far from appriciated!
the yahoo answer system is fuc.ked up.
$allcats[$ii]=mysql_result($retrievedinfo,$i,"catname");
$retrievedinfo , $i , "catname") ;
 
Back
Top