how to: multiple arrayrow results

hi, how do i get multiple arrayrows in variables?
What i have is:

<?
$sql = "SELECT cat_id, cat_title FROM tbl_category WHERE cat_parent=0";
$result = mysql_query( $sql,$connection );
while( $row=mysql_fetch_row($result) )
{
  $cat_titles[] = $row[1];

}
mysql_free_result( $result );


foreach( $cat_titles as $v )
{
  echo $v."<br />\n";
};

?>

What i want is

<?
$sql = "SELECT cat_id, cat_title FROM tbl_category WHERE cat_parent=0";
$result = mysql_query( $sql,$connection );
while( $row=mysql_fetch_row($result) )
{
  $cat_id[] = $row[0];  //  <---??
  $cat_titles[] = $row[1];

}
mysql_free_result( $result );


foreach( $cat_titles as $v ) AND ( $cat_id as $b )  // <---??
{
  echo $v."<br />\n";
  echo $b."<br />\n";
};

?>

You are using deprecated Mysql code. Plain and simple, dont use it. There is a link in my signature to a PDO bumpstart database to get you going in the right direction. Change your code to PDO or Mysqli and we will be happy to help you.

If there is an easy answer possible within this outdated mysql, then please feel free to let me know anyway.
I am not interested in learning an alternative language. I am only interested in finishing my local project.

man… i know i am ahead of the facts, but this pisses me off… your little advertisement stunt costs me all chance to get helped by someone that is actually willing to help me, and i’m stuck.
minus karma to you.

It’s not an alternative language, it’s still PHP. I’m sure you’ll find an old vet of the PHP language to help you out (maybe), but for me personally I’m not going to learn obsolete PHP in order to help someone out. You have three choices. 1. Hope some wise old timer in PHP is going to help you, 2. Go to php.net an teach yourself obsolete PHP or 3. Get with the times and switch over to mysqli or PDO (You’ll eventually going to have to do it anyways).

Just one last thing, people here take their own free time to help people out, whether they choose to or not it’s still consider rude to criticize for voicing an opinion…no make that a fact about PHP. The time and effort you put in learning obsolete PHP could have been better spent learning the correct way and it isn’t as hard as you’re making it to be. Sorry if I’m sounding rude myself, but I just want to point that out to everyone.

I know my reply is interpreted as rude and unthankfull, but his response was advertisement, and it was hijacking my question. My response on top of that made the chance to get help even less, so i better join a new forum now and repeat my question there.

I am working on a private local project that has nothing to do with scripting, but requires some scripting to progress. I know nothing of scripting, scriping is like japanese to me and telling me to just migrate to another language is like telling me japanese is yesterdays language, learn chinese. the simple answer. i can’t. i am not a technical person and these simple questions i make are the result of hundreds of hours of trying to understand this gibrish.

What advertisement stunt? I provided a link to FREE database code that that “I” personally spent many hours to write which uses current PHP code, not some “OTHER” language as you say. If you would rather spend “Hundreds of hours” on obsolete code rather than take 2 seconds to download the FREE WORKING code that I GIVE AWAY then have at it.

You will get no further assistance from me and not likely anyone else.

Stop victimizing yourself, you are here because you want to, and if you wouldve chosen to be helpfull, i would have been very thankfull. I know you must have spend a lot of work on your guide, So it comes to no surprise that you seek oportunities to advertise it to people, especially when they use outdated code, with which is nothing wrong. However. In case of this thread you decided to use it as excuse not to answer my question, so why would i be thankfull to that. If you are not in the mood to answer a question, or dont like the person that asks it (like without a doubt is the case now with me), then just dont answer it.

On top of that i find out that the little problem i posted, remains excactly the same in its updated form, making it even more of a unrelated reply.

$result = mysqli_query( $con,$sql );
while( $row=mysqli_fetch_row($result) )
{
$autoIDrow[] = $row[0];
$otherrow[] = $row[1];
}
mysqli_free_result($result);
mysqli_close($con);

foreach( $autoIDrow as $autoID )
{
echo $autoID;
echo $otherrow; <--how?
}
Sponsor our Newsletter | Privacy Policy | Terms of Service