aquaman Posted April 25, 2006 Share Posted April 25, 2006 ok .. the short version of the problem.on one page i have all the entries from a data base displayed with a "short" descrption and a link to the long description.what i would like to do is when the link is clicked it opens a window with just that entry to the database. i assumed that this would work[code]<a href="../inc/showfull.php?id=<? echo $id; ?>"> [/code]this generates the desired effect. the source code for the page reads[code]<a href="../inc/showfull.php?id=1">[/code]with the number after the = sign changing in each href depending on the db entry.but the link doesn't only show that entry. I get all the entries in the database.Would someone be so kind as to explain how to dynamically get only one entry based on the id number of the entry. or at least point me where i need to go for the information.Thanks in advance.Chris Quote Link to comment https://forums.phpfreaks.com/topic/8374-php-mysql-question/ Share on other sites More sharing options...
kenrbnsn Posted April 25, 2006 Share Posted April 25, 2006 Please post the code of the script that is displaying the data. That's where your problem is.Ken Quote Link to comment https://forums.phpfreaks.com/topic/8374-php-mysql-question/#findComment-30621 Share on other sites More sharing options...
aquaman Posted April 25, 2006 Author Share Posted April 25, 2006 Here is the code i was using. to pull the loop and add the url. I was using the same code to call the fullpage link just without the loop.[code]//select everything to display$query = "SELECT * FROM credits ORDER BY id ASC";$results = mysql_query ($query);//now we must count how many rows are in the db.$num = mysql_num_rows($results);//we have our data so we can close the db.mysql_close();//Display the results.//run a loop to show all results$i=0;while ($i < $num) {$id = mysql_result($results,$i,"id");$name = mysql_result($results,$i,"name");$position = mysql_result($results,$i,"position");$tagline = mysql_result($results,$i,"tagline");$bio = mysql_result($results,$i,"bio");$photo = mysql_result($results,$i,"photo");//now display the form?><link href="styles.css" rel="stylesheet" type="text/css" /><div align="center"> <table width="350" border="0" cellpadding="5" cellspacing="0" class="outlinebox"> <tr> <td width="110" align="left" valign="top"><img src="../headshots/<? echo $photo;?>" width="110" height="168" /></td> <td width="220" align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td><p><? echo $name;?></p></td> </tr> <tr> <td><img src="nav/images/spacer.gif" width="5" height="5" /></td> </tr> <tr> <td><p><? echo $position; ?></p></td> </tr> <tr> <td><img src="nav/images/spacer.gif" width="5" height="5" /></td> </tr> <tr> <td><p><? echo $tagline; ?>... <span class="fullbiolink">[<a href="../../inc/credits-full.php?id=<? echo $id;?>">more</a>] </span></p></td> </tr> </table></td> </tr> </table></div> <br /> <? //this will repeat the table until all rows are displayed.$i++;}?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/8374-php-mysql-question/#findComment-30629 Share on other sites More sharing options...
Ferenc Posted April 25, 2006 Share Posted April 25, 2006 This would get you what you want, but you will have to change the query on the full details[code]// to get the id passed from last page$id = $_GET['id'];$sql = mysql_query("SELECT * FROM credits WHERE id='$id'") or die(mysql_error());[/code][code]<?php//query everything to display assuming a db connection was made$sql = mysql_query("SELECT * FROM credits ORDER BY id ASC") or die(mysql_error());// no need to count the results unbless you plan to do pagination// make a while loopwhile($row = mysql_fetch_array($sql)){ // now everything is in an array $row['id']?><div align="center"> <table width="350" border="0" cellpadding="5" cellspacing="0" class="outlinebox"> <tr> <td width="110" align="left" valign="top"><img src="../headshots/<?php echo $row['photo']; ?>" width="110" height="168" /></td> <td width="220" align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td><p><?php echo $row['name'];?></p></td> </tr> <tr> <td><img src="nav/images/spacer.gif" width="5" height="5" /></td> </tr> <tr> <td><p><?php echo $row['position']; ?></p></td> </tr> <tr> <td><img src="nav/images/spacer.gif" width="5" height="5" /></td> </tr> <tr> <td><p><?php echo $row['tagline']; ?>... <span class="fullbiolink">[<a href="../../inc/credits-full.php?id=<?php echo $row['id'];?>">more</a>] </span></p></td> </tr> </table></td> </tr> </table></div><br /><?php} //end whilemysql_free_result($sql);?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/8374-php-mysql-question/#findComment-30760 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.