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
https://forums.phpfreaks.com/topic/77526-cant-display-properly/
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
https://forums.phpfreaks.com/topic/77526-cant-display-properly/#findComment-392447
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
https://forums.phpfreaks.com/topic/77526-cant-display-properly/#findComment-392452
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.