Matpatnik Posted May 27, 2007 Share Posted May 27, 2007 Hi guys,Can some one tell me what's wrong with my code please?What I'm trying to do is get a word and identify the first letter (this is fine), then It have to look in the right table and get the right row (no problem here), then look at each column and echo it (It doesn't echo any column). $lettre = $_GET['mots']{0}; $sql = "SELECT * FROM mots_" . $lettre . " WHERE " . $lettre . "_mot = '" . $_GET['mots'] . "'"; $result = mysql_query($sql) or die(mysql_error()); $i = 1; while ($row = mysql_fetch_array($result)) { echo $row["'" . $lettre . "_" . $i . "'"] . ", "; $i = $i++; } Thank you for your help Link to comment Share on other sites More sharing options...
Matpatnik Posted May 27, 2007 Author Share Posted May 27, 2007 I find my problem and changed $i = 1; while ($row = mysql_fetch_array($result)) { echo $row["'" . $lettre . "_" . $i . "'"] . ", "; $i = $i++; } for this $row = mysql_fetch_array($result); for ($i = 1; $i <= 16; $i++) { echo $row[$lettre . "_" . $i] . ", "; } Now I just have to find a way to escape the ", " when the column is empty Link to comment Share on other sites More sharing options...
Matpatnik Posted May 27, 2007 Author Share Posted May 27, 2007 It was easier than I thought, I added this before the echo if (!empty($row[$lettre . "_" . $i])) { $space = ", "; } else { $space = ""; } I work good expect the comma at the end Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.