Welcome to Dream.In.Code
Getting PHP Help is Easy!

Join 117,570 PHP Programmers for FREE! Ask your question and get quick answers from experts. There are 1,794 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



help me

 
Reply to this topicStart new topic

help me

ishlux
post 21 Jul, 2008 - 10:39 PM
Post #1


New D.I.C Head

*
Joined: 18 Jul, 2008
Posts: 7

Hi.....here i am able to display only the last row contents.....pls help me......i want to display the rows based on user selection.....here what ever u select it will disply the last row.....

php


<?php
session_start();

include('database.php');
$result = mysql_query("SELECT * FROM autoalto_mail" );

while($row = mysql_fetch_array($result))
{
?>


<tr><td width="10%"></td>
<td ><img src="images/buldot.gif" alt="" height="6" width="6">
<?echo $row['from']?></td>
<td >
<a href="contractor_mail_action_contents.php?mail_id=<? $mailid=$row['mail_id'];
session_register("mailid");
?>">






<?
session_start();
include('database.php');
$mailid1 = $_SESSION['mailid'];
echo $mailid1;
$query1="SELECT * FROM autoalto_mail where mail_id='".$mailid1."'" ;

//echo $query1;
$result = mysql_query( $query1 );
//echo mysql_num_rows($result) ;
while($row = mysql_fetch_array($result))
{
echo $row['contents'];
}
mysql_close();

?>


User is offlineProfile CardPM

Go to the top of the page


BetaWar
post 22 Jul, 2008 - 11:13 AM
Post #2


#include <soul.h>

Group Icon
Joined: 7 Sep, 2006
Posts: 1,568



Thanked 62 times

Dream Kudos: 975
My Contributions


Try something like so (I got rid of the sessions and placed a get command for which row to provide)

CODE
<?php
include('database.php');  
$result = mysql_query("SELECT * FROM  autoalto_mail" );
$output = '';
while($row = mysql_fetch_array($result)){
  $output += '<tr><td width="10%"></td>  
                <td ><img src="images/buldot.gif" alt="" height="6" width="6">  
                     ' . $row['from'] . '</td>  
                <td >  
                     <a href="contractor_mail_action_contents.php?mail_id=' . $row['mail_id'] . '">';
}
mysql_close();
echo $output;
?>
  
  
  
  
  
<?  
include('database.php');  
$mailid1 = $_GET['mail_id'];  
echo $mailid1;  
$query1="SELECT * FROM  autoalto_mail where mail_id='".$mailid1."'";  
  
//echo $query1;  
$result = mysql_query( $query1 );  
//echo mysql_num_rows($result);  
while($row = mysql_fetch_array($result))  {  
  echo $row['contents'];  
}  
mysql_close();
?>


THe only issue I believe you may run into with this is sql injection attempts so you will want to add some security (whatever type you like the most) to make sure they don't have mail_id set to something like ' or 1=1 drop table autoalto_mail ' (Which gets rid of the table called autoalto_mail, something that wouldn't be good).
User is online!Profile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 10/7/08 08:26PM

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month