Hello, l want to retrieve information from a database,, l have a section for it to load but there is two entries (for now) l want it to pick a random one and load it, how can l do this? in my html file l have Name: <?php echo $latest_deal_name; ?><br/> and so on, this loads from and external file in that external file l want it to retrieve the info from a database and a column named 'name' PLUS pick a random one from all the entries and display it, how can l do thsi?
dlannetts
0
Junior Poster in Training
Recommended Answers
Jump to PostCan you please paste some of your code ? The code of the section and any existing code in the external file ?
Jump to PostThe code you posted is what you need actually, but if you're outputting only the name, then use
SELECT name from table
in order to reduce processing cost.
In your code you need to use mysql_fetch_assoc instead of mysql_fetch_array.
Next, for random row,
I assume you have …
Jump to PostEverything looks OK to me. Can't say anything unless it is tried actually :)
At the part where you're assigning values to variables, you can simplify the code using this:
extract($info, EXTR_PREFIX_ALL, 'latest_deal');
All 10 Replies
nileshgr
dlannetts
0
Junior Poster in Training
nileshgr
waseem12
0
Newbie Poster
dlannetts
0
Junior Poster in Training
nileshgr
dlannetts
0
Junior Poster in Training
nileshgr
vaibhav1983
1
Junior Poster
nileshgr
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.