Jump to content

image links


marquis
 Share

Recommended Posts

not realy sure where to put this topic pretty sure this is the right placehere is what im trying to do when you click on an image of a house i want it to take me to a new page that has a description the description is store in a database. i dont want to have to make a new page for every house in the database. if you need any more information just ask.

Link to comment
Share on other sites

the most simple way may be this. :1. Add a table at the end of all images. And add a get variable into your link. like <a href="?house=house">2. Add this code inside the table :

<? if($_GET[house]){   $house=$_GET[house];if($house="house"){?><table width="26%"  border="1">  <tr>	<td>Location</td>	<td>the location </td>  </tr>  <tr>	<td>Rooms</td>	<td>the rooms</td>  </tr>  <tr>	<td>Price</td>	<td>the price </td>  </tr></table><? }if($house="anotherhouse"){ ?><table width="26%"  border="1">  <tr>	<td>Location</td>	<td>the location </td>  </tr>  <tr>	<td>Rooms</td>	<td>the rooms</td>  </tr>  <tr>	<td>Price</td>	<td>the price </td>  </tr></table><? }} ?>

that may be the simplest way if you want to use php.The table you have the code in will be empty before the visitor clicks a house link offcourse. ->Kristian_C

Link to comment
Share on other sites

im not sure if that would be the easyest way. what i was thinking the easyest way t do it is to sent a variblle to the description page. that varible wold contain i piece of info from the same table as the decription is coming from such as an account number and the run basicly this quieryselect * from estate where accountnum='the varible we sent through' then just echo the description.im just not sure if its possible to do that but if it is can someone tell me howso basicly the same thing a form would do with out the form

Link to comment
Share on other sites

hehe :

<?$house=$_GET['house'];$select=mysql_fetch_object(mysql_query("SELECT * FROM houses WHERE house='$house'"));?><table width="26%"  border="1">  <tr>	<td>Location</td>	<td><? echo"$select->location"; </td>  </tr>  <tr>	<td>Rooms</td>	<td><? echo"$select->rooms"; ?></td>  </tr>  <tr>	<td>Price</td>	<td><? echo"$select->price"; ?> </td>  </tr></table>

its just to add something like that on the page you want.Thought you dident want a new page :) But yeah this is the easyest way to do it :)->Kristian_C

Link to comment
Share on other sites

that not the part im having trouble with echo '<a href="descrip.php">'; echo '<img src="images/'. $row['imagename'] .'" width="400"height="400">';what would i add to this transfer the varible over i know that this is probly the dumbest question ever but i never realy learned html i just jumped into phpecho '<a href="descrip.php?accountnum=1">';echo '<img src="images/'. $row['imagename'] .'" width="400"height="400">';and then $_GET["accountnum"];i think that might be it

Link to comment
Share on other sites

that not the part im having trouble with echo '<a href="descrip.php">'; echo '<img src="images/'. $row['imagename'] .'" width="400"height="400">';what would i add to this transfer the varible over i know that this is probly the dumbest question ever but i never realy learned html i just jumped into phpecho '<a href="descrip.php?accountnum=1">';echo '<img src="images/'. $row['imagename'] .'" width="400"height="400">';and then $_GET["accountnum"];i think that might be it
That should work.ot just : <a href="descrip.php?accountnim=$avariable><img src="images/img"></a>if you have something to bring a variable to the link tho, so it shows what id it is..
Link to comment
Share on other sites

You're on the right track, just replace the hard-coded variable with the ID from the database. So instead of this:echo '<a href="descrip.php?accountnum=1">';echo '<img src="images/'. $row['imagename'] .'" width="400"height="400">';Do this:echo '<a href="descrip.php?accountnum=' . $row['id'] . '">';echo '<img src="images/'. $row['imagename'] .'" width="400"height="400">';Or whatever the ID field is called.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...