link to php script with pre-defined variable

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mrpaulfrank
Forum Commoner
Posts: 33
Joined: Sun Jun 23, 2002 3:39 am

link to php script with pre-defined variable

Post by mrpaulfrank »

im using a search script that comes up with a whole mess of results according to which genre you select. each result has an image, and each image has a hyperlink. what i would like to do is make this hyperlink execute a php script (which is generic and will be used for all hyperlinks) that shows the selected result by itself, and in more detial. what kind of variables do i need to define and in which scripts?? here is the search script:

Code: Select all

<?php 
echo "<table width="100%" border="0" cellspacing="0" cellpadding="0">\n";  // begin master table
echo "<tr>\n";  // begin master table's one and only row

do &#123;// start while loop
		$image = $row_Recordset1&#1111;'image']; // define image number for each loop	
		if($genre = "comedy")
		&#123; // start if loop
		echo "<td>\n";  // begin master table column to be repeated by loop
		echo "<table width="100%" border="0" cellspacing="0">\n"; //begin sub-table
		echo "<tr>\n";  // start sub-table row 1 
        echo "<A href=??????????><div align="center"><IMG SRC=images/$image.jpg></A></div>\n"; // insert dynamic image
        echo "<br><div align="center">".$row_Recordset1&#1111;'title']."</div>\n";  // insert dynamic title
        echo "<br><div align="center">".$row_Recordset1&#1111;'format']."</div>\n"; // insert dynamic format
		echo "</table>\n";  // end sub-table
		echo "</td>\n";  //end master table column
		&#125;
	&#125; 
while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
this is the loop that is repeated a controlled number of times. where all the ?'s are is obviously where i need to link to the php script, but i left it as ?'s becuase i dont know what i should name it yet. each item has its uniuqe 'id' number and 'image' number from the table, so one of these would be the best variable to define what video i want the script to look for. this is the script that i want it to link to (for now its named 'backcover.php):

Code: Select all

<?php
$image = $row_Recordset2&#1111;'image'];
echo "<table width="100%" border="0" cellspacing="0">\n"; //begin table
		echo "<tr>\n";  // start table row 
        echo "<div align="center"><IMG SRC=backs/$image.jpg></div>\n"; // insert dynamic image
        echo "<br><div align="center">".$row_Recordset2&#1111;'title']."</div>\n";  // insert dynamic title 
        echo "<br><div align="center">".$row_Recordset2&#1111;'actors']."</div>\n"; // insert dynamic actors
        echo "<br><div align="center">".$row_Recordset2&#1111;'description']."</div>\n"; // insert dynamic description
		echo "</tr>"; // end table row
		echo "</table>\n"; // end table
?>
any ideas?? again, i want the hyperlink in the first script to somehow link to the second script and dredge up results to the specific title's image that was clicked. all the script is there, im pretty sure i just need to define a few variables and rename the second script. anyways, please let me know what steps i should take. thank you.
mrpaulfrank
Forum Commoner
Posts: 33
Joined: Sun Jun 23, 2002 3:39 am

will this help?

Post by mrpaulfrank »

is this somewhere along the lines of what i should be trying to do??

Code: Select all

"<A href=backs/$backcover.php?image=$image><div align="center"><IMG SRC=images/$image.jpg></A></div>\n"; // insert dynamic image
that of course would be the hyperlink related to each individual image in the first script. again, what im trying to do is somehow communicate with the second script and tell it that i want to find information specific to ONE item only (by using its unique image number). can what ive done here do me any good as far as defining which item's information will show when the second script is run??
mrpaulfrank
Forum Commoner
Posts: 33
Joined: Sun Jun 23, 2002 3:39 am

Post by mrpaulfrank »

never mind. i used my intuition and came up with the correct solution.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Code: Select all

if($genre = "comedy") &#123;
I tried to point this out to you before, the code above will set the genre to comedy no matter what it started out as so the if statement will not work as expected - in order to do a comparison you need:

Code: Select all

if ($genre == 'comedy') &#123;
Mac
Post Reply