How to display the next image from database when i click the next button?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ashfaqbinnazar
    New Member
    • Apr 2010
    • 5

    How to display the next image from database when i click the next button?

    Code:
    <?php 
    session_start();
    include_once "dbutil.php";
    dbconnect();
    if(isset($_POST['review'])) $review=$_POST['review']; else $review="";
    if(isset($_POST['comment'])) $comment=$_POST['comment']; else $comment="";
    if(isset($_POST['next'])) $next=$_POST['next']; else $next="";
    include "inc\functions.php";
    $toid=$_GET['toid'];
    //echo "To id:".$toid;
    $id = $_SESSION['id'];
    //echo $id;
    //$imag= $_SESSION['imag'];
    $imag=$_GET['var'];
    if($toid=="")
    {
    $toid=$id;
    }	
    if($comment)
    { 
    if($review=="")
    {
    $msg1="*";
    }
    $time_offset ="525"; // Change this to your time zone
    $time_a = ($time_offset * 120);
    $time = date("h:i:s",time() + $time_a);
    $date=date("d/m/y");
    if($review<>"")
    {
    $sql="INSERT INTO imagereview (`from`,`toid`,`review`,`imageid`,`date`,`time`)
    VALUES ('$id','$toid','$review','$imag','$date','$time')";
    $rst=mysql_query($sql) or die(mysql_error());
    }}
    ?>
    <style type="text/css">
    <!--
    .style1 {font-family: Verdana, Arial, Helvetica, sans-serif}
    .style2 {color: #FF0000}
    -->
    </style>
    <form action="" method="post">
     <table width="100%"><tr><td align="center">
    
     <table class="BODY" cellpadding="5" width="90%"><tr><td>
    
       <!--logo-->
       <table width="100%" cellpadding="0" cellspacing="0">
         <tr>
          </table>
    
       <!--menu-->
        <table width="100%"><tr>
    			<td>
    			</td>
    	   	<td width="100%" nowrap align="right">&nbsp;</td>
        </tr>
        <table width="100%" class="menu">
         <tr>
           <td  align="right" width="100%"><?php $row1=userdata($id);  echo "You are logged in as ".$row1['username']; ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<A HREF = logout.php>Log out&nbsp;</td>
    	<td align="right" nowrap>&nbsp;</td>
          </tr>
       </table>
    <!--main content-->
    <div>
     <table width="100%" cellspacing="10" cellpadding="0" ><td align="center"><img id="nav_left" style="cursor: pointer;" src="http://static1.orkut.com/img/b_left_disable.gif">
    <img id="nav_right" style="cursor: pointer;" src="http://static4.orkut.com/img/b_right_disable.gif">
      <tr>
        <td align="center"><br />
        <table cellspacing="0" cellpadding="0">
      <?php 
    	  //$im=$imagename;
    	  //echo $id;
    	$larpic="images/profilepics/".$imag;
    	  ?>
          <tr>
            <td class="photo">
              <div style="margin: 10px;">
               <img src="<?php echo $larpic; ?>" height="533"  width="800"/></div>
         </td>
             <td valign="top">&nbsp;</td>
        </tr>
          <tr><?php if($next)
    	  {
    	  $i=$imag;
    	  echo $i;
    	  for(i=0;i<5;i++)
    	  $larpic="images/profilepics/".$imag;
    	  
    	  }
    	  ?>
            <td>&nbsp;</td>
       </tr>
          </table>
        </tr>
      <tr>
      	<td align="center">
      		<div>
    	     <table cellspacing="0" cellpadding="0" width="920">
    	       <!--<tr height="5"><td></td></tr>-->
    	       	       <tr><td width="100%" align="center"><b><font class="photodesc" size="5">IMGP7051a.JPG
    	       	         <input name="next" type="submit" id="next" value="Next" />
    	       	       </font></b></td>
    	       	       </tr>
           	       	      </table>
    	   </div>
        </td>
      <tr>
     </table>
     <table width="100%"><tr></tr>
     </table>
     <div>
      <table width="100%" class="menu">
        <tr>
        	<td width="100%"><table width="100%" border="0">
              <tr>
                <td>&nbsp;</td>
                <td><?php
    	  $rst = mysql_query("SELECT * FROM imagereview where toid='$id' and imageid='$imag'")
    	  or die(mysql_error());  
    	  $count=mysql_num_rows($rst);
    	  while($count>0)
    	 {
    	 $count--;
    	 $row = mysql_fetch_array($rst);
    	 $rev=$row['review'];
    	 $date=$row['date'];
         $time=$row['time']; 
    	 $from=$row['from'];
    	 $froname=fromname($from);
    	 $fromname=$froname['username'];
    	 $path1=fromimage($from);
    	 echo "<table width='80%' border='0'><tr>
        <td width='15%' rowspan='2'>"; ?><img src="<?php echo $path1; ?>" height="90"  width="65" border="0" hspace="10"/><?php echo "</td>
        <td valign='top' width='75%'><strong>$fromname:</td>
        <td width='16%' rowspan='2' valign='top'>$time<br>
        $date</td>
      </tr>
      <tr>
        <td valign='top'>$rev</td>
      </tr>
    </table><br>"; }?></td>
                <td>&nbsp;</td>
              </tr>
              <tr>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
              </tr>
              <tr>
                <td width="19%">&nbsp;</td>
                <td width="62%"><h2>Comments</h2></td>
                <td width="19%">&nbsp;</td>
              </tr>
              <tr>
                <td>&nbsp;</td>
                <td class="style2">
                  <textarea name="review" cols="80" rows="4" id="review"></textarea>
                  <?php if($comment) echo $msg1;?></td>
                <td>&nbsp;</td>
              </tr>
              <tr>
                <td>&nbsp;</td>
                <td><input name="comment" type="submit" id="comment" value="Post comment">
                 </td>
                <td>&nbsp;</td>
              </tr>
              
            </table></td>
        </tr>
      </table>
    </div>  
    </form>
    </body></html>
  • dlite922
    Recognized Expert Top Contributor
    • Dec 2007
    • 1586

    #2
    Nice code, what am I suppose to do with it? fix it?

    Please repost your question with a more specific (here's the part of the code that's now working) reply.

    I can't sift through all your code to find what the problem is.

    Comment

    Working...