Those dots aren't helping.
$name= $row['alias'];
Those dots aren't helping.
$name= $row['alias'];
Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum
ok thank you so much guys for your help. Just one more thing though.
The output of the name works. But there is a space between the first and second letter!!! I can't find where in the script to correct that?!?!?
It's just because there's whitespace between the two <span> tags. Remove it, and all will be fine.
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
lol thank you, silly me!!!
ok, the script is complete and it leads me onto another question. Lets say I have 10 names I want outputting into a table. I have just been trying by myself by the way!! But I am failing!!
Any ideas would be a help.
Thanks.
How are they stored?
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
Ive created a new thread which sort of runs off the previous one because I thought it is in a way a different question to the last one even though the two are related so I hope that this is ok.
Basically, I have this code that retrieves data from a table in a database.
and I have this code that outputs data from the database onto a webpage but into 2 different colours....eg.Code:<?php $dbhost = 'localhost'; $dbuser = 'dbuser'; $dbpass = 'dbpass'; $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); $dbname = 'dbname'; mysql_select_db($dbname); $query = "SELECT alias FROM challengeus"; $result = mysql_query($query) or die(mysql_error()); print " <center> <table border=\"5\" cellpadding=\"5\" cellspacing=\"0\" style=\"border-collapse: collapse\" bordercolor=\"#808080\" width=\"20%\" id=\"AutoNumber2\" bgcolor=\"#C0C0C0\"><tr> <td align=center bgcolor=\"#ffffcc\"><b>Player:</b></td> </tr>"; while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { print "<tr>"; print "<td align=center>" . $row['alias'] . "</td>"; print "</tr>"; } print "</table>"; print "</center>"; ?>
Smithster
when I put the 2 scripts together, I end up with this....Code:<style type="text/css"> .name-firstletter { color: red; } .name-rest { color: #48d1cc; } </style> </head> <body> <p> <span class="name-firstletter"> <?php echo($name[0]); ?> </span> <span class="name-rest"> <?php echo(substr($name, 1)); ?> </span> </p>
Code:<html> <style type="text/css"> .name-firstletter { color: red; } .name-rest { color: #48d1cc; } </style> <?php $dbhost = 'localhost'; $dbuser = 'dbuser'; $dbpass = 'dbpass'; $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); $dbname = 'dbname'; mysql_select_db($dbname); $query = "SELECT alias FROM challengeus"; $result = mysql_query($query) or die(mysql_error()); print " <center> <table border=\"5\" cellpadding=\"5\" cellspacing=\"0\" style=\"border-collapse: collapse\" bordercolor=\"#808080\" width=\"20%\" id=\"AutoNumber2\" bgcolor=\"#C0C0C0\"><tr> <td align=center bgcolor=\"#ffffcc\"><b>Player:</b></td> </tr>"; while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { print "<tr>"; print "<td align=center>"<span class=\"name-firstletter\"><?php echo($row[0]); ?> </span> <span class=\"name-rest\"> <?php echo(substr($row, 1)); ?> </span>"</td>"; print "</tr>"; } print "</table>"; print "</center>"; ?>
New thread created as this is really a different question. I hope the question I have asked answers this question!!
http://www.dynamicdrive.com/forums/s...4765#post94765
MODERATOR EDIT: This is the same discussion, so please only use one thread. It has already been discussed, so anyone who helps you may wish to review this thread when doing so. I merged the two threads. Please keep it this way, for this, and for future questions.
Last edited by djr33; 05-30-2007 at 10:03 PM.
The code (once put together) should look like so:
Notice how I broke out of PHP parsing mode to basically make it easier to keep track of. Hope this helps.Code:<html> <style type="text/css"> .name-firstletter { color: red; } .name-rest { color: #48d1cc; } </style> <?php $dbhost = 'localhost'; $dbuser = 'dbuser'; $dbpass = 'dbpass'; $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); $dbname = 'dbname'; mysql_select_db($dbname); $query = "SELECT alias FROM challengeus"; $result = mysql_query($query) or die(mysql_error()); ?> <center> <table border="5" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#808080" width="20%" id="AutoNumber2" bgcolor="#C0C0C0"><tr> <td align=center bgcolor="#ffffcc"><b>Player:</b></td> </tr> <?php while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { ?> <tr> <td align=center><span class="name-firstletter"><?php echo $row[0];?></span> <span class="name-rest"><?php echo substr($row, 1));?></span></td> </tr> <?php } ?> </table> </center>
"Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design
Well the script caused an error when first ran. So I put the exact HTML for the span section into it and this time there was no error. But only the top part of the table is shown. Nothing else. Something is still wrong?!?!?
Bookmarks