PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I want to make a randomaizer that selects a row from a mysql database that meets a certain condition. I have no idea how to make randomizers (never worked with them before), so I will not be a slave driver and ask you people to write a code for me. But, please reccommend good tutorials, or perhaps functions that I could look up in the PHP manual. I want to work with php as much as possible and as little as possible with MySQL. So, who can be brave and give an answer?
$db = mysql_connect("localhost", "", "") or die ("could not connect to db");
mysql_select_db("dbthawowi_2") or die ("could not select database");
$query="SELECT joke FROM table WHERE id=2.50 AND validation='yes' ORDER BY RAND() LIMIT 1";
$result=mysql_query($sql, $db);
echo $result;
This displays nothing, and I want it to display the field 'joke'.
<?php
$db = mysql_connect("localhost", "", "") or die ("could not connect to db");
mysql_select_db("dbthawowi_2") or die ("could not select database");
$sql="SELECT joke FROM table WHERE id=2.50 AND validation='yes' ORDER BY RAND() LIMIT 1";
$result=mysql_query($sql, $db);
$row = mysql_fetch_assoc($result);
echo $row["joke"];
?>
Also I'm not sure that the SQL query you indicated would work...