EPCtech Posted August 26, 2008 Share Posted August 26, 2008 Hello, I am working on a game submission system for my website, En-Psyche, and I want it to display the files uploaded by the user for them to choose for their game. $sql=mysql_query("SELECT file FROM myfiles WHERE file LIKE '%.png' OR file LIKE '%.gif' OR file LIKE '%.jpg'"); list($file)=mysql_fetch_array($sql); $sql=mysql_query("SELECT * FROM myfiles WHERE file LIKE '%.zip' OR file LIKE '%.exe' OR file LIKE '%.gmk' OR file LIKE '%.gm6' OR file LIKE '%.gmd' OR file LIKE '%.rar' OR file LIKE '%.zip' AND user='".$name."'"); list($files)=mysql_fetch_array($sql); $name has already been set. Now, when it echo's the variable, it only echo's the first result. How can I make it echo all the results. Best Regards, En-Psyche Management Link to comment https://forums.phpfreaks.com/topic/121330-displaying-files/ Share on other sites More sharing options...
DarkWater Posted August 26, 2008 Share Posted August 26, 2008 You have to loop through the result set instead of just calling mysql_fetch_array() once. Link to comment https://forums.phpfreaks.com/topic/121330-displaying-files/#findComment-625551 Share on other sites More sharing options...
EPCtech Posted August 26, 2008 Author Share Posted August 26, 2008 You have to loop through the result set instead of just calling mysql_fetch_array() once. Eh, how would I do that? En-Psyche Link to comment https://forums.phpfreaks.com/topic/121330-displaying-files/#findComment-625554 Share on other sites More sharing options...
DarkWater Posted August 26, 2008 Share Posted August 26, 2008 while ($row = mysql_fetch_assoc($sql)) { ..... } Edit: http://www.phpfreaks.com/tutorial/php-basic-database-handling/page1 Link to comment https://forums.phpfreaks.com/topic/121330-displaying-files/#findComment-625557 Share on other sites More sharing options...
EPCtech Posted August 26, 2008 Author Share Posted August 26, 2008 while ($row = mysql_fetch_assoc($sql)) { ..... } Edit: http://www.phpfreaks.com/tutorial/php-basic-database-handling/page1 But doesn't that echo the data over and over again? In which I would get the data in that echoed more than once? Link to comment https://forums.phpfreaks.com/topic/121330-displaying-files/#findComment-625561 Share on other sites More sharing options...
DarkWater Posted August 26, 2008 Share Posted August 26, 2008 No, it loops through each row of the result set. Link to comment https://forums.phpfreaks.com/topic/121330-displaying-files/#findComment-625563 Share on other sites More sharing options...
EPCtech Posted August 26, 2008 Author Share Posted August 26, 2008 No, it loops through each row of the result set. $sql=mysql_query("SELECT * FROM myfiles WHERE file LIKE '%.zip' OR file LIKE '%.exe' OR file LIKE '%.gmk' OR file LIKE '%.gm6' OR file LIKE '%.gmd' OR file LIKE '%.rar' OR file LIKE '%.zip'"); while($row = mysql_fetch_assoc($sql)){ $files=$row['file']; echo("Select stuff...Options..."); //SELECT * FROM games WHERE keywords LIKE "%really fun%" OR name LIKE "%ff%" } I get: (Oh, wait, you need to be logged in for this...hmm...) http://www.en-psyche.com/usercp?act=games§=postgame Sorry, I'll quickly make a test account. Username: "PHPFreaks" Password: "phpafterall" Thanks for any help. Link to comment https://forums.phpfreaks.com/topic/121330-displaying-files/#findComment-625568 Share on other sites More sharing options...
DarkWater Posted August 26, 2008 Share Posted August 26, 2008 $sql=mysql_query("SELECT * FROM myfiles WHERE file LIKE '%.zip' OR file LIKE '%.exe' OR file LIKE '%.gmk' OR file LIKE '%.gm6' OR file LIKE '%.gmd' OR file LIKE '%.rar' OR file LIKE '%.zip'"); while(list($file) = mysql_fetch_assoc($sql)){ echo $file . "<br />"; } Link to comment https://forums.phpfreaks.com/topic/121330-displaying-files/#findComment-625569 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.