query results

Thread Solved

Join Date: Feb 2008
Posts: 347
Reputation: kevin wood is an unknown quantity at this point 
Solved Threads: 1
kevin wood's Avatar
kevin wood kevin wood is offline Offline
Posting Whiz

query results

 
0
  #1
May 30th, 2008
after i have run my query on a mysql db how can i set the result to equal a variable that i will use later on in the page.

i have set the query up like this

  1. <?php
  2. $rand = RAND (0, 100);
  3. $query = "SELECT broad1 FROM images_broad";
  4. $result=mysql_query($query);
  5.  
  6. while($row=mysql_fetch_array($result, MYSQL_ASSOC)){
  7. $send_mail =$row['broad1'];
  8. }
  9.  
  10. ?>

i dont think the last line is correct though. could anyone please help.
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 347
Reputation: kevin wood is an unknown quantity at this point 
Solved Threads: 1
kevin wood's Avatar
kevin wood kevin wood is offline Offline
Posting Whiz

Re: query results

 
0
  #2
May 30th, 2008
is it correct and this is why i get no reply. or is no one playing out?
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 252
Reputation: ProfessorPC is an unknown quantity at this point 
Solved Threads: 27
ProfessorPC ProfessorPC is offline Offline
Posting Whiz in Training

Re: query results

 
1
  #3
May 30th, 2008
you are pulling from all rows in the db. your variable will only display the last rows info. but yes that should work for using that var later in the page.
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 347
Reputation: kevin wood is an unknown quantity at this point 
Solved Threads: 1
kevin wood's Avatar
kevin wood kevin wood is offline Offline
Posting Whiz

Re: query results

 
0
  #4
Jun 2nd, 2008
the end code look like this

  1. $query = "SELECT sent_messages FROM email_count"OR die(mysql_error());
  2. $results = mysql_query($query);
  3. $arr = mysql_fetch_array($results);
  4. $sent_mail = $arr[0];

thanks for the reply though
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC