(SOLVED) Crazy learning PHP for a UDT. Can you help...
Posted: Wed Jul 13, 2011 4:25 am
I have around 100 images that need to display randomly in a couple of locations across a CMSMadeSimple site (1.9)
All will have title tags, some will contain urls as well.
I constructed a two column table called cms_pics, with the columns: id, titletag.
Id is simply an auto increment number, title tag is the code for the image eg
{$num} is a randomly generated mumber corresponding to a row in the table
I tried to follow online tutorials but am totally lost. My UDT will accept the code below as valid, but displays nothing.
What I am trying to arrive at is an output string something like this:
This is my non working code. What do I need to fix?
You can tell me I know nothing... because it is true!
Any help would be great
All will have title tags, some will contain urls as well.
I constructed a two column table called cms_pics, with the columns: id, titletag.
Id is simply an auto increment number, title tag is the code for the image eg
Code: Select all
<img src="uploads/images/{$num}.jpg" alt="Australia" title="Australia" />
I tried to follow online tutorials but am totally lost. My UDT will accept the code below as valid, but displays nothing.
What I am trying to arrive at is an output string something like this:
Code: Select all
<img src="uploads/images/25.jpg" alt="Bicycle on Road" title="Riding the Great Ocean Road" />
Code: Select all
mysql_connect("localhost","user","password");
mysql_select_db("mydatabase");
$result = mysql_query("SELECT * FROM cms_pics WHERE id = '1' "); //id = $num
while($rows = mysql_fetch_assoc($result)){
echo $rows[$titletag];
}
Any help would be great