Jump to content

PHP + Simple Javascript Image Browser


davidz

Recommended Posts

I have a php page that gets a bunch of stuff out of a Database.  All this works great!  We have recently added two simple image browser/selector.  What I need to be able to do is pass the value of a hidden input field over to another page.  I will post the relevant code below:

 

//Start Form
<form name=Profile method=POST action=profile.php>
//Get house image references from Database
$connection = mysql_connect("192.168.100.230", "statsdb", "password") or die(mysql_error());
$db = mysql_select_db("NewStats", $connection) or die(mysql_error());
$Housesql = "SELECT AccountNum, ImageType, ImageNum, BaseDir, FileName, CountyID, FileDT, ID
		FROM taxrollImages WHERE ImageType = 'Photo' AND AccountNum = '$accountnum' AND      
CountyID = '4' ORDER BY FileDT ASC";
$Houseresult = mysql_query($Housesql, $connection) or die(mysql_error());

//Start the javascript stuff for multiple images
$houseimage = "<div style=\"width: 284px; height: 192px;\">";

//Loop through results and build the HTML for the image selection
while($Houserow = mysql_fetch_row ($Houseresult)){
//remove windows directory stuff from path
$path_to_image = substr($Houserow['3'], 3);
$path_to_image = str_replace('\\','/',$path_to_image);
$image_file_name = $Houserow['4'];
        //Mount point to images
$houseimageFile = "images/AccountImages/" . $path_to_image . $image_file_name;
$houseimage .= "
	<p class=virtualpage2>
		<input type=hidden name=IID value=$Houserow[7]>
		<img src=$houseimageFile width=284 height=192>
	</p>";
}
//Initialize the Javascript
$houseimage .= "
<div id=scriptspaginate class=paginationstyle style=\"width: 284px\">
<a href=\"#\" rel=previous>Prev</a>
<span class=paginateinfo style=\"margin: 0 30px; font-weight: bold\"></span>
<a href=\"#\" rel=next>Next</a>
</div>

<script type=\"text/javascript\">
var newscripts=new virtualpaginate(\"virtualpage2\", 1, \"p\")
newscripts.buildpagination(\"scriptspaginate\")
</script>";

//This code gets repeated again with a new query and variables etc. For a second set of images.



//submit button for stuff
<input type=submit name=ProfileSubmit value='Property Profile'>
//close form
</form>

 

 

So when I hit the submit button the next page only gets the results of the last item created.  Which can easily been see from the final output (View Source).

<div style="width: 284px; height: 192px;">
	<p class=virtualpage2>
		<input type=hidden name=IID value=52>
		<img src=images/AccountImages/AssessorNew/Photo/Photo1/0000698011.JPG width=284 height=192>
	</p>
	<p class=virtualpage2>
		<input type=hidden name=IID value=53>
		<img src=images/AccountImages/AssessorNew/Photo/Photo1/0000698021.JPG width=284 height=192>
	</p>
	<p class=virtualpage2>
		<input type=hidden name=IID value=54>
		<img src=images/AccountImages/AssessorNew/Photo/Photo1/0000698031.JPG width=284 height=192>
	</p>
	<p class=virtualpage2>
		<input type=hidden name=IID value=55>
		<img src=images/AccountImages/AssessorNew/Photo/Photo1/0000698041.JPG width=284 height=192>
	</p>
<div id=scriptspaginate class=paginationstyle style="width: 284px">
<a href="#" rel=previous>Prev</a>
<span class=paginateinfo style="margin: 0 30px; font-weight: bold"></span>
<a href="#" rel=next>Next</a>
</div>

<script type="text/javascript">
var newscripts=new virtualpaginate("virtualpage2", 1, "p")
newscripts.buildpagination("scriptspaginate")
</script>

 

 

After all that... What I need to do is when I click the button I need it to know which image I am on so I can get the right ID number from the html tags.

 

Here is the page I got the image browser from:

http://www.dynamicdrive.com/dynamicindex17/virtualpagination.htm

The one we are using is on the right hand side, second one down.

 

Thanks!

 

PS Sorry if this is confusing, the total code for the page is over 1500 lines so I did not want to post the whole thing.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.