Jump to content

I'm having a problem with my script.


vetman

Recommended Posts

I guess I don't know what I'm doing, I have written this script to post pictures with a search form to search for items by year, it works fine but I thought I could just change my url statement by adding this (?id=10 or something similar) to the end of the file name and have it display and individual item. It doesn't work. Can someone point me in the right direction?

Thanks in advance.

 

form.php

<html>
<head>
<title>Corvette Promotional Page</title>
<link rel="stylesheet" type="text/css"
media="screen" href="page_style.php">
<title>Gold Specimens</title>
    <script type="text/javascript" src="highslide/highslide.js"></script>
    <script type="text/javascript">
        hs.graphicsDir = 'highslide/graphics/';
        hs.showCredits = false;
     </script>

     <style type="text/css">
	* {
	    font-family: Verdana, Helvetica;
	    font-size: 10pt;
	}
	.highslide {
		cursor: url(highslide/graphics/zoomin.cur), pointer;
	    outline: none;
	}
	.highslide-active-anchor img {
		visibility: hidden;
	}
	.highslide img {
		border: 2px solid gray;
	}
	.highslide:hover img {
		border: 2px solid white;
	}
	.highslide-wrapper {
		background: white;
	}
	.highslide-image {
		border: 10px solid white;
	}
	.highslide-image-blur {
	}
	.highslide-caption {
	    display: none;
	    border: 5px solid white;
	    border-top: none;
	    padding: 5px;
	    background-color: white;
	}
	.highslide-loading {
	    display: block;
		color: black;
		font-size: 8pt;
		font-family: sans-serif;
		font-weight: bold;
	    text-decoration: none;
		padding: 2px;
		border: 1px solid black;
	    background-color: white;

	    padding-left: 22px;
	    background-image: url(highslide/graphics/loader.white.gif);
	    background-repeat: no-repeat;
	    background-position: 3px 1px;
	}
	a.highslide-credits,
	a.highslide-credits i {
	    padding: 2px;
	    color: silver;
	    text-decoration: none;
		font-size: 10px;
	}
	a.highslide-credits:hover,
	a.highslide-credits:hover i {
	    color: white;
	    background-color: gray;
	}

	a.highslide-full-expand {
		background: url(highslide/graphics/fullexpand.gif) no-repeat;
		display: block;
		margin: 0 10px 10px 0;
		width: 34px;
		height: 34px;
	}

	/* These must always be last */
	.highslide-display-block {
	    display: block;
	}
	.highslide-display-none {
	    display: none;
	}
    /* image display - centered */
       IMG.displayed {
            margin-left:auto;
            margin-right:auto;
        }


</style>
</head>
<body>
<center><table border="0"><IMG class="displayed" src="logo-1.jpg" border="1" alt="logo">
<tr><td align="center" colspan="3">
<form method="post" action="search_year.php">
<input type="text" name="search" size=6 maxlength=10>
<input type="Submit" name="Submit" value="Search">
</form>
</td></tr><br>

 

search_year.php

<?php
include 'config.php';
include 'form.php';
$tbl_name="promo";
$search=$_POST["search"];
$con = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
mysql_select_db("rwts_webmaster") or die(mysql_error());

$query = "SELECT * FROM $tbl_name WHERE year LIKE '%$search%'";



$result = mysql_query($query) or die("There was a problem with the SQL query: " . mysql_error());
if($result && mysql_num_rows($result) > 0)

{
    $i = 0;
    $max_columns = 3;
echo "<br>";
    while($row = mysql_fetch_array($result))
   {
       // make the variables easy to deal with
       extract($row);

       // open row if counter is zero
       if($i == 0)

          echo "<tr>";

          echo "<td align=center>";
          ?>
          <div>
               <a id="thumb1" href="<?php echo $picture; ?>" class="highslide" onclick="return hs.expand(this)">
	<img src="<?php echo $thumb; ?>" title="Click to enlarge" /></a>
          <div class="highslide-caption"><?php echo $id; ?></div>



          <?php
          echo "</td>";

       // increment counter - if counter = max columns, reset counter and close row
       if(++$i == $max_columns)
       {
           echo "</tr>";
           $i=0;
       }  // end if
   } // end while
} // end if results

// clean up table - makes your code valid!
if($i > 0)
{
    for($j=$i; $j<$max_columns;$j++)
        echo "<td> </td>";
   echo '</tr>';
}
mysql_close($con);
?>
</table>
</body>
</html>

Link to comment
Share on other sites

I hadn't tried that, but just did and the page showed nothing. I also tried search_year.php?id=10 , got the complete listing of the website. I guess I'm not the only one that is lost.

Thanks for you time.

 

What are you trying to do? The GET superglobal has to be handled, for example:

getyear.php?ID=10

if (isset($_GET['ID'])) {
   $ID = (int)$_GET['ID']
   $sql =  ... WHERE ID = $ID..
   //list ID 10
} else {
   //List all results
}

 

 

 

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.