acctman Posted August 28, 2007 Share Posted August 28, 2007 Does this query code look right? I'm trying to pull all mp3 entries for user "m_id" and then display the results in a list. <? $mp3user = mysql_query("SELECT `mp3_id`,`mp3_userid`,`mp3_title` FROM `rate_mp3s` WHERE `mp3_userid` = 'm_id'"); echo "<ul>\n"; while($row = mysql_fetch_array($mp3user)) { echo "<li>".$row['mp3_id']. "-" .$row['mp3_userid']. "-" .$row['mp3_title']."</li>\n"; } echo "</ul>\n"; ?> output should be 101-2332-Tile1 102-2332-Tile2 103-2332-Tile3 104-2332-Tile4 Quote Link to comment https://forums.phpfreaks.com/topic/67076-solved-query-code-and-echoing-results/ Share on other sites More sharing options...
Jessica Posted August 28, 2007 Share Posted August 28, 2007 is mp3_userid a number? like $m_id perhaps instead of the string 'm_id'? Quote Link to comment https://forums.phpfreaks.com/topic/67076-solved-query-code-and-echoing-results/#findComment-336381 Share on other sites More sharing options...
trq Posted August 28, 2007 Share Posted August 28, 2007 Besides that fact that there is no error handling, it looks fine. Does it work? Quote Link to comment https://forums.phpfreaks.com/topic/67076-solved-query-code-and-echoing-results/#findComment-336382 Share on other sites More sharing options...
acctman Posted August 28, 2007 Author Share Posted August 28, 2007 is mp3_userid a number? like $m_id perhaps instead of the string 'm_id'? yes mp3_userid and m_id are both numbers Quote Link to comment https://forums.phpfreaks.com/topic/67076-solved-query-code-and-echoing-results/#findComment-336385 Share on other sites More sharing options...
acctman Posted August 28, 2007 Author Share Posted August 28, 2007 Besides that fact that there is no error handling, it looks fine. Does it work? haven't tested yet, i have some other buggy coding i'm working on that i'm fixing. How do I add an errorhandler? Quote Link to comment https://forums.phpfreaks.com/topic/67076-solved-query-code-and-echoing-results/#findComment-336389 Share on other sites More sharing options...
Jessica Posted August 28, 2007 Share Posted August 28, 2007 Well no..'m_id' is a string. $m_id is a variable which could be a number. So change 'm_id' to $m_id. Quote Link to comment https://forums.phpfreaks.com/topic/67076-solved-query-code-and-echoing-results/#findComment-336390 Share on other sites More sharing options...
acctman Posted August 28, 2007 Author Share Posted August 28, 2007 thanks everyone, coding works. one other question how do i do a Count 1 2 3 output for each line print? i.e. MP3 1: Unknown MP3 Title | Delete MP3 2: Unknown MP3 Title | Delete MP3 3: Unknown MP3 Title | Delete right now, its printing MP3 : Unknown MP3 Title | Delete MP3 : Unknown MP3 Title | Delete MP3 : Unknown MP3 Title | Delete Quote Link to comment https://forums.phpfreaks.com/topic/67076-solved-query-code-and-echoing-results/#findComment-336767 Share on other sites More sharing options...
Fadion Posted August 28, 2007 Share Posted August 28, 2007 $counter = 0; while($row = mysql_fetch_array($mp3user)) { echo "<li>MP3" . $counter . " " . $row['mp3_id'] . "-" . $row['mp3_userid'] . "-" . $row['mp3_title'] . "</li>\n"; $counter++; } Quote Link to comment https://forums.phpfreaks.com/topic/67076-solved-query-code-and-echoing-results/#findComment-336776 Share on other sites More sharing options...
acctman Posted August 29, 2007 Author Share Posted August 29, 2007 $counter = 0; while($row = mysql_fetch_array($mp3user)) { echo "<li>MP3" . $counter . " " . $row['mp3_id'] . "-" . $row['mp3_userid'] . "-" . $row['mp3_title'] . "</li>\n"; $counter++; } thanks Quote Link to comment https://forums.phpfreaks.com/topic/67076-solved-query-code-and-echoing-results/#findComment-336817 Share on other sites More sharing options...
acctman Posted August 29, 2007 Author Share Posted August 29, 2007 one last question, with my current coding would I receive an error if the rate_mp3s table is empty and no data is available for a user? Quote Link to comment https://forums.phpfreaks.com/topic/67076-solved-query-code-and-echoing-results/#findComment-336829 Share on other sites More sharing options...
Jessica Posted August 29, 2007 Share Posted August 29, 2007 i don't think so...try it and see. you should always check for any possible error-causing situations in the code though. Quote Link to comment https://forums.phpfreaks.com/topic/67076-solved-query-code-and-echoing-results/#findComment-336843 Share on other sites More sharing options...
acctman Posted August 29, 2007 Author Share Posted August 29, 2007 i don't think so...try it and see. you should always check for any possible error-causing situations in the code though. thanks for the tips Quote Link to comment https://forums.phpfreaks.com/topic/67076-solved-query-code-and-echoing-results/#findComment-336911 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.