Jump to content

[SOLVED] Array of troubles


phatgreenbuds

Recommended Posts

In the code below I thought I was pulling specific fields from a row in my query and sticking them into an array...then I thought I was shuffling that array to randomize the order...it all worked to his point. However now when I try to pull the shuffled info out of the array to use it in a string, all I get is a blank page. This should work. Anyone got any idea why its not? Am I on crack and missing something obvious?

 

<?php
$query = "SELECT * FROM $tblname";
$content = mysql_query($query); 

$num = mysql_num_rows($content);	
if ($num != 0) { 
$xml = "test\r\n";																						

$count = 0;
while ($row = mysql_fetch_array($content) && $count < 10) { 															
			$con[$count] = $row["win_path"];
			$count++;
			}

shuffle($row);					
$count1 = 0;
while ($count1 < 10) {
			$xml .="blah blah is" . $con[$count1] . "\r\n";
			$count1++;
			}
			echo $xml;
}

//print_r($con);

?>

Link to comment
https://forums.phpfreaks.com/topic/125124-solved-array-of-troubles/
Share on other sites

You just want 10 random rows right?

 

<?php
$query = "SELECT * FROM $tblname ORDER BY RAND() LIMIT 10";
$content = mysql_query($query); 

while ($list = mysql_fetch_array($content)) {
  echo "blah blah is" . $list['win_path'] . "\r\n";
}

 

Also if the only column you are using is 'win_path' then you should only select that from your table:

 

<?php
$query = "SELECT win_path FROM $tblname ORDER BY RAND() LIMIT 10";
$content = mysql_query($query); 

while ($list = mysql_fetch_array($content)) {
  echo "blah blah is" . $list['win_path'] . "\r\n";
}

 

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.