Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP MYSQL Query Issue

Status
Not open for further replies.

digatle

Technical User
Joined
Oct 31, 2003
Messages
85
Location
US
I cannot figure out what I'm missing in order to get the each row the following information out of MySQL.

category_id category_blog_id category_label

I got the ability to pull one of them but the others I cannot get.

$category = mysql_query( "SELECT `category_label` FROM `mt_category` WHERE 1 AND `category_blog_id`=".$blog_id." ORDER BY `category_id` ASC;" );

Here's what I'm displaying:

<?php
while ($a_row = mysql_fetch_row( $category ) ) {
foreach ( $a_row as $field )
print &quot;<option value=&quot;}
?>

What I'm trying to get from this is
Where am I missing in this code to be able to get the category_id along with the name ($field)?

Digatle
 
Sql statement is messed up:

$category = mysql_query( &quot;SELECT `category_label` FROM `mt_category` WHERE `category_blog_id`=&quot;.$blog_id.&quot; ORDER BY `category_id` ASC;&quot; );

then you can echo the stuff back

Code:
while ($a_row = mysql_fetch_array( $category ) ) {
     $field=$a_row['field']
     $sid  =$a_row['sid'];
     $blogid=$a_row['blog_id'];

print &quot;<option value=&quot;[URL unfurl="true"]http://localhost/index2.php?sid=$sid&blogid=1>$field</option>\n&quot;;[/URL]
}

Bastien

Any one have a techie job in Toronto, I need to work...being laid off sucks!
 
I've made some modification to the code to read the following:

<?php
while ($a_row = mysql_fetch_array( $category ) ) {
$field=$a_row['category_label'];
$sid2=$a_row['category_blog_id'];
$blogid2=$a_row['category_id'];
print &quot;<option value=&quot;.FS_WEB_NAME.&quot;home.php?sid=$sid2&blogid=$blogid2>$field</option>&quot;;
}
?>

Now the label shows up. But the other two (category_blog_id and category_id) do not show up as values. Am I doing something wrong?

Digatle
 
With print the variables don't show unless you change the statement to:

print &quot;<option value=&quot;.FS_WEB_NAME.&quot;home.php?sid=&quot;.$sid2.&quot;&blogid=&quot;.$blogid2.&quot;>&quot;.$field.&quot;</option>&quot;;


or change the print to echo

Bastien

Any one have a techie job in Toronto, I need to work...being laid off sucks!
 
$category = mysql_query( &quot;SELECT `category_id`, `category_blog_id`, `category_label` FROM `mt_category` WHERE `category_blog_id`=&quot;.$blog_id.&quot; ORDER BY `category_id` ASC;&quot; );

This fixed it. Thanks!!

WILL SOMEONE HIRE BASTIEN IN TORONTO!

Digatle
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top