943,578 Members | Top Members by Rank

Ad:
  • MySQL Discussion Thread
  • Marked Solved
  • Views: 1031
  • MySQL RSS
May 30th, 2008
0

query results

Expand Post »
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

MySQL Syntax (Toggle Plain Text)
  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.
Similar Threads
Reputation Points: 27
Solved Threads: 1
Posting Whiz
kevin wood is offline Offline
347 posts
since Feb 2008
May 30th, 2008
0

Re: query results

is it correct and this is why i get no reply. or is no one playing out?
Reputation Points: 27
Solved Threads: 1
Posting Whiz
kevin wood is offline Offline
347 posts
since Feb 2008
May 30th, 2008
1

Re: query results

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.
Reputation Points: 31
Solved Threads: 29
Posting Whiz in Training
ProfessorPC is offline Offline
270 posts
since Dec 2007
Jun 2nd, 2008
0

Re: query results

the end code look like this

MySQL Syntax (Toggle Plain Text)
  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
Reputation Points: 27
Solved Threads: 1
Posting Whiz
kevin wood is offline Offline
347 posts
since Feb 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in MySQL Forum Timeline: help needed!
Next Thread in MySQL Forum Timeline: mysql question





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC