vetman Posted January 27, 2010 Share Posted January 27, 2010 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> Quote Link to comment https://forums.phpfreaks.com/topic/190059-im-having-a-problem-with-my-script/ Share on other sites More sharing options...
teamatomic Posted January 28, 2010 Share Posted January 28, 2010 ?ID= to the end of what file name, form.php? HTH Teamatomic Quote Link to comment https://forums.phpfreaks.com/topic/190059-im-having-a-problem-with-my-script/#findComment-1002748 Share on other sites More sharing options...
vetman Posted January 28, 2010 Author Share Posted January 28, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/190059-im-having-a-problem-with-my-script/#findComment-1002821 Share on other sites More sharing options...
oni-kun Posted January 28, 2010 Share Posted January 28, 2010 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 } Quote Link to comment https://forums.phpfreaks.com/topic/190059-im-having-a-problem-with-my-script/#findComment-1002823 Share on other sites More sharing options...
teamatomic Posted January 28, 2010 Share Posted January 28, 2010 To use something like ?ID=10 you need to do this: $id=$_GET['ID']; when the file is called by the url with the query string on it you will be able to do something with it. Just tacking it on to the end of a url does not do the trick. HTH Teamatomic Quote Link to comment https://forums.phpfreaks.com/topic/190059-im-having-a-problem-with-my-script/#findComment-1002826 Share on other sites More sharing options...
vetman Posted January 28, 2010 Author Share Posted January 28, 2010 I figured it out, changed POST to GET works the way I wanted it to. Quote Link to comment https://forums.phpfreaks.com/topic/190059-im-having-a-problem-with-my-script/#findComment-1002938 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.