spillage Posted May 6, 2008 Share Posted May 6, 2008 Sorry to be a noobie pain in the butt but having problems trying to work this one out. if $cust=$_POST['all']{ while($row = mysql_fetch_array($result)) { echo $row['printer_type']." | ".$row['Cust_Email']," | ".$row['Friends_Email']; echo "<br />"; }} else if $cust=$_POST['cust'] { while($row = mysql_fetch_array($result)) { echo $row['printer_type']." | ".$row['Cust_Email']," | "; echo "<br />"; }} $cust is from a drop down menu which is working as I can echo the result and get the corrct output and though the above would work but have searched around the correct answer without joy and starting to really struggling. If I am (and probally am) being a thick idiot please let me know and Ill spent a while longer searching for the answer as I quite often have my brain in the wrong gear. Cheers, Spill Quote Link to comment https://forums.phpfreaks.com/topic/104426-solved-using-an-array-with-a-db-query/ Share on other sites More sharing options...
Barand Posted May 6, 2008 Share Posted May 6, 2008 I may be missing something but is there a question in there? Quote Link to comment https://forums.phpfreaks.com/topic/104426-solved-using-an-array-with-a-db-query/#findComment-534578 Share on other sites More sharing options...
spillage Posted May 6, 2008 Author Share Posted May 6, 2008 sorry all that happens is the second script runs. So if $cust=$_POST['all'] only first two rows are printed. although if I also add at the beforehand echo $cust then 'all' is printed??? Cheers. Quote Link to comment https://forums.phpfreaks.com/topic/104426-solved-using-an-array-with-a-db-query/#findComment-534585 Share on other sites More sharing options...
Barand Posted May 6, 2008 Share Posted May 6, 2008 What is your SQL query? That's going to control the results Quote Link to comment https://forums.phpfreaks.com/topic/104426-solved-using-an-array-with-a-db-query/#findComment-534588 Share on other sites More sharing options...
spillage Posted May 6, 2008 Author Share Posted May 6, 2008 is as follows $result = mysql_query("SELECT * FROM submit WHERE printer_type LIKE '%$printer%'"); if this is used with while($row = mysql_fetch_array($result)) { echo $row['printer_type']." | ".$row['Cust_Email'],"; echo "<br />"; } this works fine regardless of which $row I select to be printed. But am trying to select the results printed. Spill Quote Link to comment https://forums.phpfreaks.com/topic/104426-solved-using-an-array-with-a-db-query/#findComment-534596 Share on other sites More sharing options...
sasa Posted May 6, 2008 Share Posted May 6, 2008 try if ($cust == 'all') etc. Quote Link to comment https://forums.phpfreaks.com/topic/104426-solved-using-an-array-with-a-db-query/#findComment-534597 Share on other sites More sharing options...
spillage Posted May 6, 2008 Author Share Posted May 6, 2008 Thanks very much sasa. Works a treat. Spill Quote Link to comment https://forums.phpfreaks.com/topic/104426-solved-using-an-array-with-a-db-query/#findComment-534619 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.