Hello, I'm really new to PHP so I've been having some trouble figuring out how to set up a code on my site.
What I want it to do is pull a random name from my database and display it centered. So far I have this code -
[pre]<?php
$link = mysql_connect("host", "user", "pass") or die (mysql_error ());
mysql_select_db ('cbnames', $link) or die (mysql_error ());
$sql = mysql_query ("SELECT `name` FROM `cb` ORDER BY RAND() LIMIT 0,1") or die (mysql_error ());
$res = mysql_fetch_assoc ($sql);
$randomname = $res['name'];
echo $randomname;
?>[/pre]
It works well at pulling up a random name but I still haven't figured out how to center it.
Next what I need is for it to display an image above the pulled name also centered. The image I need is from a web link and I need the last part of the link to be the same as the random name pulled from the database.
Example ~
If the code I have pulled the random name Michael
The link to the image to be displayed would be ~
http://www.mysite.com:/names/namesdisplay.php?char=Michael
or
If the code pulled the name Jill the image link would need to be
http://www.mysite.com:/names/namesdisplay.php?char=Jill
Etc
I hope that makes sense, I'm really hopping its a simple code but since I'm not very good at PHP I've been struggling.
I hope someone can help me out, it will be greatly appreciated!
Thanks!