seany02 Posted April 26, 2009 Share Posted April 26, 2009 Im trying to create a table with embedded links. The idea is that the table in the code below shows a brief amout of data, the user clicks the embedded link and goes to a page displaying further information. Somewhere along the way ive messed up, i know the table works before the embedded links bit is added so it isnt the sql. any help would be greatly appreciated. <?php $db = mysql_connect("localhost","root","") or die("Problem connecting"); mysql_select_db("rufus") or die("Problem selecting database"); $query = "SELECT * FROM project ORDER BY project_id"; $result = mysql_query($query) or die ("Query failed"); //let's get the number of rows in our result so we can use it in a for loop $numofrows = mysql_num_rows($result); echo "<TABLE BORDER=\"1\">\n"; echo "<TR bgcolor=\"ff6633\"><TD>Project ID</TD><TD>Project Name</TD><TD>Project Description</TD><TD>Read More</TD></TR>\n"; for($i = 0; $i < $numofrows; $i++) { $row = mysql_fetch_array($result); //get a row from our result set if($i % 2) { //this means if there is a remainder echo "<TR bgcolor=\"ff6633\">\n"; } else { //if there isn't a remainder we will do the else echo "<TR bgcolor=\"ff9900\">\n"; } echo "<TD>".$row['project_id']."</TD><TD>".$row['project_name']."</TD><TD>".$row['project_description']."<TD>".$row['email']."</TD><td>\n"; echo '<a href="viewmore.php?project_id=$result_row[project_id].'">Click</a></TR>\n"; } //now let's close the table and be done with it echo "</TABLE>\n"; ?> Link to comment https://forums.phpfreaks.com/topic/155703-help-please/ Share on other sites More sharing options...
DjMikeS Posted April 26, 2009 Share Posted April 26, 2009 A couple of things: When opening a new topic, you should choose a title that describes your problem...That way, users can quickly determine if they are able to help you... Second, please tell us what your problem is and any error messages you get... Link to comment https://forums.phpfreaks.com/topic/155703-help-please/#findComment-819539 Share on other sites More sharing options...
seany02 Posted April 26, 2009 Author Share Posted April 26, 2009 sorry! my problem is that i want to embed a link in a table and cant. echo '<a href="viewmore.php?project_id=$result_row[project_id].'">Click</a></TR>\n"; somethings not working around this i think the browser error i get is Parse error: parse error, expecting `','' or `';'' in C:\xampp\htdocs\prosearch1.php on line 77 Link to comment https://forums.phpfreaks.com/topic/155703-help-please/#findComment-819546 Share on other sites More sharing options...
shadiadiph Posted April 26, 2009 Share Posted April 26, 2009 not 100% sure but try this echo '<td><a href='viewmore.php?project_id='.$result_row[project_id].''>Click</a></td>\n'; if not try echo '<td><a href='viewmore.php?project_id='.$result_row[project_id].''>Click</a></td>'; Link to comment https://forums.phpfreaks.com/topic/155703-help-please/#findComment-819553 Share on other sites More sharing options...
FaT3oYCG Posted April 26, 2009 Share Posted April 26, 2009 sorry! my problem is that i want to embed a link in a table and cant. echo '<a href="viewmore.php?project_id=$result_row[project_id].'">Click</a></TR> "; somethings not working around this i think the browser error i get is Parse error: parse error, expecting `','' or `';'' in C:xampphtdocsprosearch1.php on line 77 echo('<a href="viewmore.php?project_id=' . $result_row[project_id] . '">Click</a></TR> '); Link to comment https://forums.phpfreaks.com/topic/155703-help-please/#findComment-819556 Share on other sites More sharing options...
shadiadiph Posted April 26, 2009 Share Posted April 26, 2009 isnt that going to look a bit odd with a stray </tr> at the end thats what i couldn't figure out Link to comment https://forums.phpfreaks.com/topic/155703-help-please/#findComment-819558 Share on other sites More sharing options...
mrMarcus Posted April 26, 2009 Share Posted April 26, 2009 what is this whole mess of a line : echo "<TD>".$row['project_id']."</TD><TD>".$row['project_name']."</TD><TD>".$row['project_description']."<TD>".$row['email']."</TD><td>\n"; you got TD tags all over. Link to comment https://forums.phpfreaks.com/topic/155703-help-please/#findComment-819559 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.