Jump to content

Save rows in Array


Marcel1993

Recommended Posts

Hey,

 

my code doesnt work and I dont know why:

 

$update_weed_world_data_sql = "SELECT weed_factor, weed_basis FROM worlds";
$update_weed_world_data_res = mysql_query($update_weed_world_data_sql) OR DIE (mysql_error());
while($update_weed_world_data_while = mysql_fetch_assoc($update_weed_world_data_res)){
$update_weed_world_basis[''.$update_weed_world_data_while['id'].''] = $update_weed_world_data_while['weed_basis'];
$update_weed_world_factor[''.$update_weed_world_data_while['id'].''] = $update_weed_world_data_while['weed_factor'];
}

 

I want to save some rows in variables identifiable by the value in the array.

 

As example. When I want to echo $update_weed_world_factor['1'] - I want to get the row with ID 1 and the column "world_factor".

 

I've used this code long time ago - but know something was going wrong.

 

Thanks for helping :-)

Link to comment
https://forums.phpfreaks.com/topic/222702-save-rows-in-array/
Share on other sites

Thank you but that didn't lead to any difference:

 

$update_weed_world_data_sql = "SELECT weed_factor, weed_basis FROM worlds";
$update_weed_world_data_res = mysql_query($update_weed_world_data_sql) OR DIE (mysql_error());
while($update_weed_world_data_while = mysql_fetch_assoc($update_weed_world_data_res)){
$update_weed_world_id = $update_weed_world_data_while['id'];
$update_weed_world_basis[$update_weed_world_id] = $update_weed_world_data_while['weed_basis'];
$update_weed_world_factor[$update_weed_world_id] = $update_weed_world_data_while['weed_factor'];
}

echo $update_weed_world_factor[1];

Link to comment
https://forums.phpfreaks.com/topic/222702-save-rows-in-array/#findComment-1151673
Share on other sites

echo out the ids to make sure you are getting them

also the first item in the array starts at 0

$update_weed_world_id = $update_weed_world_data_while['id'];
echo $update_weed_world_data_while['id'];
$update_weed_world_basis[$update_weed_world_id] = $update_weed_world_data_while['weed_basis'];
$update_weed_world_factor[$update_weed_world_id] = $update_weed_world_data_while['weed_factor'];

Link to comment
https://forums.phpfreaks.com/topic/222702-save-rows-in-array/#findComment-1151680
Share on other sites

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.