Jump to content

Can't display properly


holladb

Recommended Posts

Hey anybody got a solution for this, im trying to display all of the "subcat01called" fields. I'm having no luck though...

 

for ($i=1; $i<=1; $i++) {
$handbags = '';
$accessories = '';
$jewelry = '';
$scarves = '';

$sql = "SELECT * FROM terms WHERE cereal=$i";
//print($sql . "<br>");
$result = $db->query($sql);
$countem = '1';

while($row = $result->fetch()) {
	if ($i==1) {
		$handbags .= 'aI("text=' . $row['subcat01called'] . ';url=javascript:void(0);"); ';
	}

} 
} 

Link to comment
Share on other sites

Try running

SELECT * FROM terms WHERE cereal=1;

from the terminal or using some GUI tool (MySQL Query Browser, phpMyAdmin etc.). Does that return multiple rows? If no, then there is your answer.

 

It should only display one result, because that is what your telling it to do with the for loop. Explain exactly what your trying to do.

No it doesn't, the query could still return more than one row thus going through the while loop multiple times.

Link to comment
Share on other sites

another programmer started on this, im not sure why he put the loop in...

 

the code is going into milonic menu....so each variable stands as a menu title if you will.

 

the database query should grab all content for subcat01 and display it... as $handbags

Link to comment
Share on other sites

It should only display one result, because that is what your telling it to do with the for loop. Explain exactly what your trying to do.

No it doesn't, the query could still return more than one row thus going through the while loop multiple times.

 

Yes, but that is not what I meant. They had put $i in their query, and the for loop only runs once, so $i would only be equal to 1. I thought they were trying to change the query up for each iteration of the loop, but that wouldn't work since $i wouldn't change. I was thinking more along the lines of it only displaying one set of results. I worded that last post horribly.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.