sasori Posted February 11, 2010 Share Posted February 11, 2010 need help, i have this table data (<td>) , it is being pulled from the db, and it appears like this in my code <td><?php echo $row->title; ?></td> my question is, how will combine it with javascript ,let's say when someone onclick the title, the description will pop out , this description is being pulled from db. if i will do it like this <td id="title"><?php echo $row->title; ?></td> this is for only a single table data right? but what if the time goes by and more titles are being added on db ? Quote Link to comment https://forums.phpfreaks.com/topic/191778-how-to-use-a-db-data-as-html-id/ Share on other sites More sharing options...
Catfish Posted February 11, 2010 Share Posted February 11, 2010 you havent included any code so here is an example of how to print out multiple field values from rows returned from the database if ($dbConn = mysql_connect('user', 'pass', 'host')) { $dbQuery = "SELECT * FROM table WHERE something = 'some text'"; if ($dbResult = mysql_query($dbQuery)) { while ($row = mysql_fetch_assoc($dbResult)) { print($row['FieldName'].'<br/>'."\n"); } } else print('Could not get result from query '.$dbQuery.'<br/>Error given: '.$mysql_error().'<br/>'."\n"); } else print('Could not connect to db.<br/>'."\n"); Quote Link to comment https://forums.phpfreaks.com/topic/191778-how-to-use-a-db-data-as-html-id/#findComment-1010872 Share on other sites More sharing options...
sasori Posted February 11, 2010 Author Share Posted February 11, 2010 ok sir, thanks but that's not the solutions, let me re-phrase my question. How am I gonna make the $row->title, pop its description $row->description when some random user clicks it ? <?php foreach($task->result() as $row): ?> <tr> <td><a href=#><?php echo $row->title; ?></a></td> </tr> <?php endforeach; ?> Quote Link to comment https://forums.phpfreaks.com/topic/191778-how-to-use-a-db-data-as-html-id/#findComment-1010875 Share on other sites More sharing options...
Catfish Posted February 11, 2010 Share Posted February 11, 2010 it depends on what you mean by "pop its description". if a tooltip would suffice for this "pop"ing, you can simply use a title attribute in the HTML: <tr> <td><a title="<?php echo $row->description; ?>" href=#><?php echo $row->title; ?></a></td> </tr> Quote Link to comment https://forums.phpfreaks.com/topic/191778-how-to-use-a-db-data-as-html-id/#findComment-1010944 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.