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
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";
}

 

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.