Click here to Skip to main content
15,894,907 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Php / mysql gallery issues

I have made a gallery in php. It receives from an index page an "inname" parameter. The gallery every time it passes from page does not manage to send 2 parameters at the same time and in all inombre. Unparameter of the database "idtext"

Please tell me the mistakes

index.php
Lista de Acontecimientos<Br />  <?php
$conexion = mysqli_connect("localhost", "root", "") or trigger_error(mysql_error(),E_USER_ERROR);
mysqli_select_db($conexion,"db674013292");
$consulta="Select * from textos where clase=1 ";
$result=mysqli_query($conexion,$consulta);
?>
 <?php
 while($fila=mysqli_fetch_row($result)){
echo "<a href=\"H.php?inombre='".$fila['0']."'\">".$fila['1']."</a><br>"; 
  }
 ?>

Gallery.php
<?php
$inombre=$_GET['inombre'];

		$objConnect =  mysql_connect("localhost","root","") or die(mysql_error());
		$objDB =  mysql_select_db("db674013292");
		
		$strSQL = "SELECT * FROM galeriadecidiendo where idtexto =$inombre ";

		$objQuery = mysql_query($strSQL);
		$Num_Rows = mysql_num_rows($objQuery);

		$Per_Page = 8;   // Per Page

		@$Page = $_GET["Page"];
		if(!@$_GET["Page"])
		{
			$Page=1;
		}

		$Prev_Page = $Page-1;
		$Next_Page = $Page+1;

		$Page_Start = (($Per_Page*$Page)-$Per_Page);
		if($Num_Rows<=$Per_Page)
		{
			$Num_Pages =1;
		}
		else if(($Num_Rows % $Per_Page)==0)
		{
			$Num_Pages =($Num_Rows/$Per_Page) ;
		}

		else
		{
			$Num_Pages =($Num_Rows/$Per_Page)+1;
			$Num_Pages = (int)$Num_Pages;
		}

		$strSQL .=" order  by idgaleriatexto ASC LIMIT $Page_Start , $Per_Page";
		$objQuery  = mysql_query($strSQL);


		echo"<table border=\"0\" align=\"center\" cellspacing=\"0\" cellpadding=\"0\"><tr>";
		$intRows = 0;
		while($objResult = mysql_fetch_array($objQuery))
		{
			echo "<td>"; 
			$intRows++;
	?>
<img with="150" height="150" src="<?=$objResult["url"]; ?>"><br>                 
	<?PHP
			echo"</td>";
			if(($intRows)%4==0)
			{
				echo"</tr>";
			}
		}
		echo"</tr></table>";
	?>
		<br>
	<span class="paguinas">Total <?= $Num_Rows;?> Record : <?=$Num_Pages;?> Page :</span>
		<?PHP
		
		$consulta="Select * from textos  where idtexto =$inombre ";
$result=mysqli_query($conexion,$consulta);
		if($Prev_Page)
		{
			 while($fila=mysqli_fetch_row($result)){
			echo " 
			<a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page&?$inombre=$objResult[idtexto];'>
			
			<< Back</a> ";  }
		}

		for($i=1; $i<=$Num_Pages; $i++){
			if($i != $Page)
			{
while($fila=mysqli_fetch_row($result)){
echo "<a href='$_SERVER[SCRIPT_NAME]?Page=?$i&inombre='".$fila['0']."'\">".$fila['1']."</a><br>"; 

  }}
			else
			{	
				echo " $i ";
			}
		}
		if($Page!=$Num_Pages)
		{
			echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page&inombre=idtexto'>Next>></a> ";
		}
		?>
	<?PHP
mysql_close($objConnect);
?> <br />


What I have tried:

I tried to link one page to another
Posted
Updated 9-Jun-17 22:20pm
v2

1 solution

I have already changed the code to mysqli but the problem persists since I wrongly send the parameter inname every time that page step please as I send it


<?php
$inombre=$_GET['inombre'];

		$objConnect =  mysqli_connect("localhost","root","") or die(mysql_error());
		$objDB =  mysqli_select_db($objConnect,"db674013292");
		
		$strSQL = "SELECT * FROM galeriadecidiendo where idtexto =$inombre ";

		$objQuery = mysqli_query($objConnect,$strSQL);
		$Num_Rows = mysqli_num_rows($objQuery);

		$Per_Page = 8;   // Per Page

		@$Page = $_GET["Page"];
		if(!@$_GET["Page"])
		{
			$Page=1;
		}

		$Prev_Page = $Page-1;
		$Next_Page = $Page+1;

		$Page_Start = (($Per_Page*$Page)-$Per_Page);
		if($Num_Rows<=$Per_Page)
		{
			$Num_Pages =1;
		}
		else if(($Num_Rows % $Per_Page)==0)
		{
			$Num_Pages =($Num_Rows/$Per_Page) ;
		}
		else
		{
			$Num_Pages =($Num_Rows/$Per_Page)+1;
			$Num_Pages = (int)$Num_Pages;
		}


		$strSQL .=" order  by idgaleriatexto ASC LIMIT $Page_Start , $Per_Page";
		$objQuery  = mysqli_query($objConnect,$strSQL);


		echo"<table border=\"0\" align=\"center\" cellspacing=\"0\" cellpadding=\"0\"><tr>";
		$intRows = 0;
		while($objResult = mysqli_fetch_array($objQuery))
		{
			echo "<td>"; 
			$intRows++;
	?>
<img with="150" height="150" src="<?=$objResult["url"]; ?>"><br>                 
	<?PHP
			echo"</td>";
			if(($intRows)%4==0)
			{
				echo"</tr>";
			}
		}
		echo"</tr></table>";
	?>
		<br>
	<span class="paguinas">Total <?= $Num_Rows;?> Record : <?=$Num_Pages;?> Page :</span>
		
		
				<?PHP
		if($Prev_Page)
		{
			echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page&$inombre=idtexto'><< Back</a> ";
		}

		for($i=1; $i<=$Num_Pages; $i++){
			if($i != $Page)
			{
				echo "[ <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page&$inombre=idtexto'>$i</a> ]";
			}
			else
			{
				echo " $i ";
			}
		}
		if($Page!=$Num_Pages)
		{
			echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page$Prev_Page&$inombre=idtexto'>Next>></a> ";
		}
		?>


	<?PHP
mysqli_close($objConnect);
?> 




</body>
</html>
 
Share this answer
 
Comments
Afzaal Ahmad Zeeshan 10-Jun-17 4:22am    
Does this code solve your problem? If not, please do not post updates as solutions. Instead use the Improve question button and update the information from there.
Member 10419621 10-Jun-17 7:57am    
Thank you . By the comment. Lamejora of switching from sql to sqli has not served much

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900