Jump to content

vet911

Members
  • Posts

    100
  • Joined

  • Last visited

Everything posted by vet911

  1. I'm having trouble with my code, any help would be appreciated. I'm trying to add an if statement that checks if $new =1, if it does it echos "new" else it echos "old". What is happening is if $new ="0 or 1 " it echos the same answer. Here is partial code: $result = mysql_query("SELECT * FROM $dbname WHERE new = '1'") or die(mysql_error()); // store the record of the "" table into $row $current = ''; // keeps getting the next row until there are no more to get while($row = mysql_fetch_array( $result )) { $id = $row['id']; if (!$current) { echo "<center><div><table border='0' width='520'>"; $current = $id; echo "<img src='images/jewelry.png' alt='toveco'/><br/>"; echo "<div>"; echo "Questions about store items use link in menu.<br/>"; echo "Latest (".$rows5.") "; echo "Beads (".$rows4.") "; echo "Cabochons (".$rows3.") "; echo "Earrings (".$rows1.") "; echo "Pendants (".$rows2.") "; echo "Rings (".$rows0.") "; echo "</div>"; echo "<p><b>Click picture to enlarge.</b></p>"; echo "<hr width='520'>"; } elseif ($current != $id){ echo "</table></div><br><div><table border='0' width='520'>"; $current = $id; echo "<hr width='520'>"; } ?> <tr><td rowspan="9" width="110"><div class="image"><a href="<?= $row['image']; ?>" rel="lightbox" title="<?= $row['material']; ?>"><img src="<?= $row['image_th']; ?>" align="center" border="0"></a></div></td> <td rowspan="9" width="110"><div class="image"><a href="<?= $row['image2']; ?>" rel="lightbox" title="<?= $row['material']; ?>"><img src="<?= $row['image2_th']; ?>" width="75" border="0"></a></div></td> <tr><td> <?php if ($new=="0") echo "new"; else echo "old "; ?> </td></tr> <tr><th align="left">Item No.</th><td><?= $row['itemno']; ?></td></tr> <tr><th align="left">Description</th><td><?= $row['description']; ?></td></tr> <tr><th align="left">Cut</th><td><?= $row['cut']; ?></td></tr> <tr><th align="left">Carat</th><td><?= $row['carat']; ?></td></tr> <tr><th align="left">Material</th><td><?= $row['material']; ?></td></tr> <tr><th align="left">Price</th><td><?= $row['price']; ?></td></tr> <tr><th align="left">Availability</th><td><?= $row['availability']; ?></td></tr> <tr><th></th> <td></td>
  2. Thanks, that worked fine. I tried using the wild card in the query before I posted but when I put it in ( $results = mysql_query("SELECT * FROM members WHERE upper($field) LIKE'%$find%'"); I had it in both places, front and back, didn't think to place it in the back only. When it was in both it found all cases of the search letter in all places which was what I didn't want.
  3. I have code to search a database of members, I can search by lastname but having a little problem. I want to be able to search by lastname starting with the first letter. (ie: a or b or c or d and so on). As it is right now I can only search by first letter of last name if I add % to the search (ie: a% b% c%) will give me all members with the last names starting with the approiate letter designation. I'm not sure how to handle this, any help would be appreciated. Thanks. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> </head> <body> <center><table cellspacing="10" cellpadding="10" width="750" border="0"> <h4>Search</h4> <form name="search" method="post" action="<?php $PHP_SELF?>"> Seach for: <input type="text" name="find" /> in <Select NAME="field"> <Option VALUE="lname">Last Name</option> <input type="hidden" name="searching" value="yes" /> <input type="submit" name="search" value="Search" /> </form> <?php // check to see if anything is posted if (isset($_POST['find'])) {$find = $_POST['find'];} if (isset($_POST['searching'])) {$searching = $_POST['searching'];} if (isset($_POST['field'])) {$field = $_POST['field'];} //This is only displayed if they have submitted the form if (isset($searching) && $searching=="yes") { echo "<h4>Results</h4><p>"; // If they did not enter a search term we give them an error if (empty($find)) { echo "<p>You forgot to enter a search term"; exit; } // Otherwise we connect to our Database mysql_connect("localhost", "root", "1910") or die(mysql_error()); mysql_select_db("cmc_member") or die(mysql_error()); // We preform a bit of filtering $find = strtoupper($find); $find = strip_tags($find); $find = trim ($find); // Now we search for our search term, in the field the user specified $results = mysql_query("SELECT * FROM members WHERE upper($field) LIKE'$find'"); // And we display the results if($results && mysql_num_rows($results) > 0) { $i = 0; $max_columns = 3; while($row = mysql_fetch_array($results)) { // make the variables easy to deal with extract($row); // open row if counter is zero if($i == 0) echo "<tr>"; // make sure we have a valid product ALIGN='CENTER' if($fname != "" && $fname != null) echo "<td ALIGN='CENTER'><FONT COLOR='red'><b>$fname $lname</b></FONT><br> $address <br> $city $state $zip <br>$phone<br><a href=\"mailto: $email\">$email</a><br></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 < $max_columns) { for($j=$i; $j<$max_columns;$j++) echo "<td> </td>"; } //This counts the number or results - and if there wasn't any it gives them a little message explaining that $anymatches = mysql_num_rows($results); if ($anymatches == 0) { echo "Sorry, but we can not find an entry to match your query<br><br>"; } //And we remind them what they searched for echo "<b>Searched For:</b> " .$find; } ?> </tr> </table></center> </body> </html>
  4. I got the email link to work. Any help on the columns? Below is what I used. echo "<tr><td><a href=\"mailto:{$row['email']}\">{$row['email']}</a></td></tr>";
  5. I have a database of members showing name, address, city, state, zip, phone and email address. I want to make the email address a link in my table on the webpage, and I would like to make 3 columns instead of one that happens now. Any help would be appreciated, thanks in advance. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <title></title> <head> <link rel="stylesheet" href="./stylesheet/stylesheet1.css" media="screen"> <style type="text/css" media="screen">@import url("./stylesheet/stylesheet2.css");</style> </head> <body> <?php // Make a MySQL Connection $con = mysql_connect(localhost, root, 1910) or die ('Error connecting to mysql'); mysql_select_db("cmc_member") or die(mysql_error()); echo "Connected to Database <br>"; // Retrieve all the data from the "members" table $result = mysql_query("SELECT * FROM members ORDER BY lname") or die(mysql_error()); // store the record of the "cmc_member" table into $row $current = ''; // keeps getting the next row until there are no more to get while($row = mysql_fetch_array( $result )) { $id = $row['id']; if (!$current) { echo "<center><br><div><table border='0' width='250'>"; $current = $id; } elseif ($current != $id){ echo "</table></div><br><br><div><table border='0' width='250'>"; $current = $id; } // Print out the contents of each row into a table echo "<tr><td>{$row['fname']} {$row['lname']}</td></tr>"; echo "<tr><td>{$row['address']}</td></tr>"; echo "<tr><td>{$row['city']} {$row['state']} {$row['zip']}</td></tr>"; echo "<tr><td>{$row['phone']}</td></tr></div>"; echo "<tr><td>{$row['email']}</td></tr>"; } echo "</table></div></center>"; ?> </body> </html>
  6. That was it, I replaced what you said. It works now! Thanks very much for your time.
  7. I tried replacing the php tags to the full <?php ?> and now the footer shows up but not the pagination. <?php include 'form_j.php'; $tbl_name="images"; $search=$_POST["search"]; $con = mysql_connect("localhost", "root", "1910") or die ('Error connecting to mysql'); mysql_select_db("test") or die(mysql_error()); $query = "SELECT * FROM $tbl_name"; $result = mysql_query($query) or die("There was a problem with the SQL query: " . mysql_error()); if($result && mysql_num_rows($result) > 0) //Place code to connect to your DB here. // How many adjacent pages should be shown on each side? $adjacents = 2; /* First get total number of rows in data table. If you have a WHERE clause in your query, make sure you mirror it here. */ $query = "SELECT COUNT(*) as num FROM $tbl_name"; $total_pages = mysql_fetch_array(mysql_query($query)); $total_pages = $total_pages[num]; /* Setup vars for query. */ $targetpage = "image_test_2.php"; //your file name (the name of this file) $limit = 4; //how many items to show per page $page = $_GET['page']; if($page) $start = ($page - 1) * $limit; //first item to display on this page else $start = 0; //if no page var is given, set start to 0 /* Get data. */ $sql = "SELECT * FROM $tbl_name LIMIT $start, $limit"; $result = mysql_query($sql); /* Setup page vars for display. */ if ($page == 0) $page = 1; //if no page var is given, default to 1. $prev = $page - 1; //previous page is page - 1 $next = $page + 1; //next page is page + 1 $lastpage = ceil($total_pages/$limit); //lastpage is = total pages / items per page, rounded up. $lpm1 = $lastpage - 1; //last page minus 1 /* Now we apply our rules and draw the pagination object. We're actually saving the code to a variable in case we want to draw it more than once. */ $pagination = ""; if($lastpage > 1) { $pagination .= "<div class=\"pagination\">"; //previous button if ($page > 1) $pagination.= "<a href=\"$targetpage?page=$prev\">previous</a>"; else $pagination.= "<span class=\"disabled\">previous</span>"; //pages if ($lastpage < 7 + ($adjacents * 2)) //not enough pages to bother breaking it up { for ($counter = 1; $counter <= $lastpage; $counter++) { if ($counter == $page) $pagination.= "<span class=\"current\">$counter</span>"; else $pagination.= "<a href=\"$targetpage?page=$counter\">$counter</a>"; } } elseif($lastpage > 5 + ($adjacents * 2)) //enough pages to hide some { //close to beginning; only hide later pages if($page < 1 + ($adjacents * 2)) { for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++) { if ($counter == $page) $pagination.= "<span class=\"current\">$counter</span>"; else $pagination.= "<a href=\"$targetpage?page=$counter\">$counter</a>"; } $pagination.= "..."; $pagination.= "<a href=\"$targetpage?page=$lpm1\">$lpm1</a>"; $pagination.= "<a href=\"$targetpage?page=$lastpage\">$lastpage</a>"; } //in middle; hide some front and some back elseif($lastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2)) { $pagination.= "<a href=\"$targetpage?page=1\">1</a>"; $pagination.= "<a href=\"$targetpage?page=2\">2</a>"; $pagination.= "..."; for ($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++) { if ($counter == $page) $pagination.= "<span class=\"current\">$counter</span>"; else $pagination.= "<a href=\"$targetpage?page=$counter\">$counter</a>"; } $pagination.= "..."; $pagination.= "<a href=\"$targetpage?page=$lpm1\">$lpm1</a>"; $pagination.= "<a href=\"$targetpage?page=$lastpage\">$lastpage</a>"; } //close to end; only hide early pages else { $pagination.= "<a href=\"$targetpage?page=1\">1</a>"; $pagination.= "<a href=\"$targetpage?page=2\">2</a>"; $pagination.= "..."; for ($counter = $lastpage - (2 + ($adjacents * 2)); $counter <= $lastpage; $counter++) { if ($counter == $page) $pagination.= "<span class=\"current\">$counter</span>"; else $pagination.= "<a href=\"$targetpage?page=$counter\">$counter</a>"; } } } //next button if ($page < $counter - 1) $pagination.= "<a href=\"$targetpage?page=$next\">next</a>"; else $pagination.= "<span class=\"disabled\">next</span>"; $pagination.= "</div>\n"; } ?> <?php { $i = 0; $max_columns = 2; 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>"; ?> <div> <a id="thumb1" href="images/<?php echo $image; ?>" class="highslide" onclick="return hs.expand(this)"> <img src="images/<?php echo $image; ?>" title="Click to enlarge" width = "300"/></a> <div class="highslide-caption"><?php echo $id; ?> <?php echo $caption; ?></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></br> <?php $pagination ?> <?php require 'footer_j.php';?>
  8. I don't get an error. The pictures show but there is no pagination showing the other pages. I have 6 pictures in the database, 4 show on the page, the other 2 are missing because of the pagination not working.
  9. I have included the php file I'm using. It is currently working on the internet, but doesn't work local. I'm not sure why. The last 2 lines of code call for the pagination and a footer of which neither show up on my local system. Any help would be appreciated. This is the script working on my site on the internet. http://vetstuf.com/jewelry/jewelry3_1.php <?php include 'form_j.php'; $tbl_name="images"; $search=$_POST["search"]; $con = mysql_connect("localhost", "root", "1910") or die ('Error connecting to mysql'); mysql_select_db("test") or die(mysql_error()); $query = "SELECT * FROM $tbl_name"; $result = mysql_query($query) or die("There was a problem with the SQL query: " . mysql_error()); if($result && mysql_num_rows($result) > 0) //Place code to connect to your DB here. // How many adjacent pages should be shown on each side? $adjacents = 2; /* First get total number of rows in data table. If you have a WHERE clause in your query, make sure you mirror it here. */ $query = "SELECT COUNT(*) as num FROM $tbl_name"; $total_pages = mysql_fetch_array(mysql_query($query)); $total_pages = $total_pages[num]; /* Setup vars for query. */ $targetpage = "image_test_2.php"; //your file name (the name of this file) $limit = 4; //how many items to show per page $page = $_GET['page']; if($page) $start = ($page - 1) * $limit; //first item to display on this page else $start = 0; //if no page var is given, set start to 0 /* Get data. */ $sql = "SELECT * FROM $tbl_name LIMIT $start, $limit"; $result = mysql_query($sql); /* Setup page vars for display. */ if ($page == 0) $page = 1; //if no page var is given, default to 1. $prev = $page - 1; //previous page is page - 1 $next = $page + 1; //next page is page + 1 $lastpage = ceil($total_pages/$limit); //lastpage is = total pages / items per page, rounded up. $lpm1 = $lastpage - 1; //last page minus 1 /* Now we apply our rules and draw the pagination object. We're actually saving the code to a variable in case we want to draw it more than once. */ $pagination = ""; if($lastpage > 1) { $pagination .= "<div class=\"pagination\">"; //previous button if ($page > 1) $pagination.= "<a href=\"$targetpage?page=$prev\">previous</a>"; else $pagination.= "<span class=\"disabled\">previous</span>"; //pages if ($lastpage < 7 + ($adjacents * 2)) //not enough pages to bother breaking it up { for ($counter = 1; $counter <= $lastpage; $counter++) { if ($counter == $page) $pagination.= "<span class=\"current\">$counter</span>"; else $pagination.= "<a href=\"$targetpage?page=$counter\">$counter</a>"; } } elseif($lastpage > 5 + ($adjacents * 2)) //enough pages to hide some { //close to beginning; only hide later pages if($page < 1 + ($adjacents * 2)) { for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++) { if ($counter == $page) $pagination.= "<span class=\"current\">$counter</span>"; else $pagination.= "<a href=\"$targetpage?page=$counter\">$counter</a>"; } $pagination.= "..."; $pagination.= "<a href=\"$targetpage?page=$lpm1\">$lpm1</a>"; $pagination.= "<a href=\"$targetpage?page=$lastpage\">$lastpage</a>"; } //in middle; hide some front and some back elseif($lastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2)) { $pagination.= "<a href=\"$targetpage?page=1\">1</a>"; $pagination.= "<a href=\"$targetpage?page=2\">2</a>"; $pagination.= "..."; for ($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++) { if ($counter == $page) $pagination.= "<span class=\"current\">$counter</span>"; else $pagination.= "<a href=\"$targetpage?page=$counter\">$counter</a>"; } $pagination.= "..."; $pagination.= "<a href=\"$targetpage?page=$lpm1\">$lpm1</a>"; $pagination.= "<a href=\"$targetpage?page=$lastpage\">$lastpage</a>"; } //close to end; only hide early pages else { $pagination.= "<a href=\"$targetpage?page=1\">1</a>"; $pagination.= "<a href=\"$targetpage?page=2\">2</a>"; $pagination.= "..."; for ($counter = $lastpage - (2 + ($adjacents * 2)); $counter <= $lastpage; $counter++) { if ($counter == $page) $pagination.= "<span class=\"current\">$counter</span>"; else $pagination.= "<a href=\"$targetpage?page=$counter\">$counter</a>"; } } } //next button if ($page < $counter - 1) $pagination.= "<a href=\"$targetpage?page=$next\">next</a>"; else $pagination.= "<span class=\"disabled\">next</span>"; $pagination.= "</div>\n"; } ?> <?php { $i = 0; $max_columns = 2; 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>"; ?> <div> <a id="thumb1" href="images/<?php echo $image; ?>" class="highslide" onclick="return hs.expand(this)"> <img src="images/<?php echo $image; ?>" title="Click to enlarge" width = "300"/></a> <div class="highslide-caption"><?php echo $id; ?> <?php echo $caption; ?></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></br> <?=$pagination?> <? require 'footer_j.php';?>
  10. I implimented both suggestions, it now works as explained. Thanks to you both for the help.
  11. I thought it worked fine until I noticed that there wasn't 4 item in the first set of 1963. There were only 3 items listed, but from there on it put the correct number in each row. this is what was needed: 1963, 1963, 1963, 1963 1965, 1965, 1965 1978 This is what I got: 1963, 1963, 1963 1965, 1965, 1965 1978 I couldn't figure what was wrong. I made sure the items were in the database and they were. Any thoughts? Thanks
  12. I am searching the database for items that are plaques. There are different years of plaques. I find all the plaques sorted by year. My display puts them in rows of 4 max. What I want is to display them by year with a different year on a different line. Right now there are 4 (1963), 3 (1965), 1 (1978) all bunched together. 1963, 1963, 1963, 1963, 1965, 1965, 1965, 1978 What I want is: 1963, 1963, 1963, 1963, 1965, 1965, 1965, 1978, Any help would greatly be appreciated. <?php include 'config0.php'; $search=$_GET["search"]; // Connect to server and select database. mysql_connect($dbhost, $dbuser, $dbpass)or die("cannot connect"); mysql_select_db("$dbname")or die("cannot select DB"); $result = mysql_query("SELECT * FROM table1 WHERE plaques LIKE '%$search%' ORDER BY year") or die(mysql_error()); // store the record of the "" table into $row //$current = ''; // keeps getting the next row until there are no more to get if($result && mysql_num_rows($result) > 0) { $i = 0; $max_columns = 4; echo "<table align=center>"; 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 style="float: left;"> <div><img src="<?php echo $tn; ?>"></div> </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(); ?> </table>
  13. Thank you, that worked perfectly. I found out that the alt tag is for images that don't show up and the title tag was what I wanted. Thanks again.
  14. I need some help with an alt tag for an image. I can't get it to show up, your help will be appreciated. This is my code inside a div. I need it to show up when you move your mouse over the image like it would normally do. Because of the php code I can't seem to find out how to do it. <div style="float: left;"><a href="tn1_1.php?search=<?php echo $title; ?>"><img src="<?php echo $tn; ?>"><h4><?php echo $title; ?></h4></a></div>
  15. Thanks for the quick response. I thought I was getting the $year from the select statement, which would have it as one of the variables. Is this not possible?
  16. I'm having trouble echoing $year in my script. Listed below is the script, just below ,$result = mysql_query("SELECT * FROM $dbname WHERE class LIKE '%$search%'") or die(mysql_error());, in the script I try to echo $year. It doesn't show up in the table on the webpage. Everything else works fine. Any help wold be appreciated greatly. Thanks in advance. <?php include 'config2.php'; $search=$_GET["search"]; // Connect to server and select database. mysql_connect($dbhost, $dbuser, $dbpass)or die("cannot connect"); mysql_select_db("vetman")or die("cannot select DB"); $result = mysql_query("SELECT * FROM $dbname WHERE class LIKE '%$search%'") or die(mysql_error()); // store the record of the "" table into $row //$current = ''; echo "<table align=center border=1>"; echo "<br>"; echo "<tr>"; echo "<td align=center>"; ?> <div style="float: center;"><a><h1><?php echo $year; ?></h1></a></div> <?php echo "</td>"; echo "</tr>"; echo "</table>"; // keeps getting the next row until there are no more to get if($result && mysql_num_rows($result) > 0) { $i = 0; $max_columns = 2; echo "<table align=center>"; 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 style="float: left;"> <div><img src="<?php echo $image1; ?>"></div> </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(); ?> </table>
  17. Thanks for the info. I kind of knew something was different after the join of the tables. I have attached pdfs of the tables, table1, table2. You will see the problem is one table has images of thumbnails, the other table has multiple images that are linked to one of the thumbnails. My thought was to link them so I could show all the thumbnails for a particular year and then when I click the link show all the images that are part of that particular thumbnail images family. (ie 1954-01 when clicked would show all 1954-01-01, 1954-01-02, 1954-01-03 etc.) Currently this only works when they are only one set of pictures. I am new to PHP, mysql, but enjoy the challange. Can you give me some advice? [attachment deleted by admin]
  18. I'm have a problem with my joined tables! I am now getting 6 of 1 image before it goes on to the next one. I wasn't getting this before the join. Can anyone help? Thanks in advance. <?php include 'config1.php'; $search=$_GET["search"]; // Connect to server and select database. mysql_connect($dbhost, $dbuser, $dbpass)or die("cannot connect"); mysql_select_db("xxxxx")or die("cannot select DB"); $query = "SELECT table1.year, table2.year, table2.group, table2.image1, table1.tn, table1.title, table1.link FROM table1 LEFT JOIN table2 ON table1.year = table2.year"; $result = mysql_query($query) or die(mysql_error()); // keeps getting the next row until there are no more to get if($result && mysql_num_rows($result) > 0) { $i = 0; $max_columns = 6; echo "<table>"; 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 style="float: left;"> <div><a href="<?php echo $link; ?>"><img src="<?php echo $tn; ?>"></a></div> <div><?php echo $title; ?></div> </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(); ?> </table>
  19. Yes, I do have the variable spelled correctly in a table, but the wrong table I just found out. Thank you for your time and expertise.
  20. I need help with my script! I search the database and post the thumbnail pictures, I have an href statement that I want the link I put in the database to link to the picture. When I look at the html code the href is blank. I don't know what wrong, please help. Below is the code: Thanks for your help. <?php include 'config1.php'; include 'form.php'; $search=$_GET["search"]; // Connect to server and select database. mysql_connect($dbhost, $dbuser, $dbpass)or die("cannot connect"); mysql_select_db("xxxxxx")or die("cannot select DB"); $result = mysql_query("SELECT * FROM $dbname WHERE year LIKE '%$search%'") or die(mysql_error()); // store the record of the "" table into $row //$current = ''; // keeps getting the next row until there are no more to get if($result && mysql_num_rows($result) > 0) { $i = 0; $max_columns = 6; echo "<table>"; 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 style="float: left;"> <div><a href="<?php echo $link; ?>"><img src="<?php echo $tn; ?>"></a></div> <div><?php echo $title; ?></div> </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(); ?>
  21. I'm have trouble getting my script to show images in a table across the screen. I want to show the picture and have the description shown below it. Right now it shows it in a column with the name next to it. Any help would be greatly appreciated. Thanks in advance. Below is the script. <?php include 'config1.php'; // Connect to server and select database. mysql_connect($dbhost, $dbuser, $dbpass)or die("cannot connect"); mysql_select_db("vetman")or die("cannot select DB"); $result = mysql_query("SELECT * FROM $dbname WHERE year = '1954'") or die(mysql_error()); // store the record of the "" table into $row //$current = ''; // keeps getting the next row until there are no more to get if($result && mysql_num_rows($result) > 0) { $i = 0; $max_columns = 3; echo "<table>"; 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><img src="<?php echo $tn; ?>"</a><a><?php echo $title; ?></a></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(); ?> </table>
  22. Okay, I though I had it until I got this error message: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/content/r/i/g/rigtway/html/toveco/store/records_test.php on line 64 This is line 64: echo "<input type='hidden' name='item_name' value='<?php $row['description'];?>'>"; Any help would be appreciated! Thank you while($row = mysql_fetch_array( $result )) { $id = $row['id']; if (!$current) { echo "<center><div><table border='0' width='520'>"; $current = $id; echo "<div id='box'>"; echo "<h4>Welcome to the Store</h4>"; echo "<p>Questions about store items use link in menu.</p>"; echo "Beads (".$rows4.") "; echo "Cabochons (".$rows3.") "; echo "Earrings (".$rows1.") "; echo "Pendants (".$rows2.") "; echo "Rings (".$rows0.") "; echo "</div>"; echo "<p>Click picture to enlarge.</p>"; echo "<hr width='520'>"; } elseif ($current != $id){ echo "</table></div><br><div><table border='0' width='520'>"; $current = $id; echo "<hr width='520'>"; } ?> <tr><td rowspan="6" width="100"><div class="image"><a href="<?= $row['image']; ?>" rel="lightbox" title="<?= $row['material']; ?>"><img src="<?= $row['image_th']; ?>" align="center" border="0"></a></div></td> <td rowspan="6" width="100"><div class="image"><a href="<?= $row['image2']; ?>" rel="lightbox" title="<?= $row['material']; ?>"><img src="<?= $row['image2_th']; ?>" width="75" border="0"></a></div></td> <th width='100' align="left">Item No.</th><td><?= $row['itemno']; ?></div> </td></tr> <tr><th align="left">Description</th><td><?= $row['description']; ?></td></tr> <tr><th align="left">Carat</th><td><?= $row['carat']; ?></td></tr> <tr><th align="left">Material</th><td><?= $row['material']; ?></td></tr> <tr><th align="left">Price</th><td><?= $row['price']; ?></td></tr> <tr><th align="left">Availability</th><td><?= $row['availability']; ?></td></tr> <tr><th> </th><td> </td><td> <?php if (!$sold){ echo "<form target='paypal' action='https://xxx.com/cgi-bin/webscr' method='post'>"; echo "<input type='hidden' name='cmd' value='_cart'>"; echo "<input type='hidden' name='add' value='1'>"; echo "<input type='hidden' name='business' value=' '>"; echo "<input type='hidden' name='item_name' value='<?php $row['description'];?>'>"; echo "<input type='hidden' name='item_number' value='<?php $row['itemno']; ?>'>"; echo "<input type='hidden' name='amount' value='<?php $row['price']; ?>'>": echo "<input type='hidden' name='shipping' value='7.00'>"; echo "<input type='hidden' name='shipping2' value='0.50'>"; echo "<input type='hidden' name='handling' value='2.00 '>"; echo "<input type='hidden' name='currency_code' value='USD'>"; echo "<input type='hidden' name='return' value='http://store/paypal/thankyou.html'>": echo "<input type='hidden' name='undefined_quantity' value='1'>"; echo "<input type='image' src='http://images.paypal.com/en_US/i/btn/btn_cart_SM.gif' height='65%' border='0' name='submit' alt='Make payments with PayPal - it's fast, free and secure!'>"; echo "</form>"; }$if ($sold) {<img src="/images/sold.gif">}?> </td> </tr>
  23. I need some help with showing a Paypal buy button or not if it's sold. Currently if the item is sold I mark it as sold but the button is still there. What I need I believe is an if statement to look at the sold variable to see if it's sold and then not show the Paypal Buy it button for that item only. Any help would be greatly appreciated. Below is some of the code I use. $result = mysql_query("SELECT * FROM $dbname ORDER BY itemno ASC") or die(mysql_error()); // store the record of the "" table into $row $current = ''; // keeps getting the next row until there are no more to get while($row = mysql_fetch_array( $result )) { $id = $row['id']; if (!$current) { echo "<center><div><table border='0' width='520'>"; $current = $id; echo "<div id='box'>"; echo "<h4>Welcome to the Store</h4>"; echo "<p>Questions about store items use link in menu.</p>"; echo "Beads (".$rows4.") "; echo "Cabochons (".$rows3.") "; echo "Earrings (".$rows1.") "; echo "Pendants (".$rows2.") "; echo "Rings (".$rows0.") "; echo "</div>"; echo "<p>Click picture to enlarge.</p>"; echo "<hr width='520'>"; } elseif ($current != $id){ echo "</table></div><br><div><table border='0' width='520'>"; $current = $id; echo "<hr width='520'>"; } ?> <tr><td rowspan="6" width="100"><div class="image"><a href="<?= $row['image']; ?>" rel="lightbox" title="<?= $row['material']; ?>"><img src="<?= $row['image_th']; ?>" align="center" border="0"></a></div></td> <td rowspan="6" width="100"><div class="image"><a href="<?= $row['image2']; ?>" rel="lightbox" title="<?= $row['material']; ?>"><img src="<?= $row['image2_th']; ?>" width="75" border="0"></a></div></td> <th width='100' align="left">Item No.</th><td><?= $row['itemno']; ?></div> </td></tr> <tr><th align="left">Description</th><td><?= $row['description']; ?></td></tr> <tr><th align="left">Carat</th><td><?= $row['carat']; ?></td></tr> <tr><th align="left">Material</th><td><?= $row['material']; ?></td></tr> <tr><th align="left">Price</th><td><?= $row['price']; ?></td></tr> <tr><th align="left">Availability</th><td><?= $row['availability']; ?></td></tr> <tr><th> </th><td> </td><td><form target="paypal" action="https://www.paypal.com" method="post"> <input type="hidden" name="cmd" value="_cart"> <input type="hidden" name="add" value="1"> <input type="hidden" name="business" value=""> <input type="hidden" name="item_name" value="<?= $row['description']; ?>"> <input type="hidden" name="item_number" value="<?= $row['itemno']; ?>"> <input type="hidden" name="amount" value="<?= $row['price']; ?>"> <input type="hidden" name="shipping" value="7.00"> <input type="hidden" name="shipping2" value="0.50"> <input type="hidden" name="handling" value="2.00 "> <input type="hidden" name="currency_code" value="USD"> <input type="hidden" name="return" value="thankyou.html"> <input type="hidden" name="undefined_quantity" value="1"> <input type="image" src="" height="65%" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!"> </form> </td> </tr>
  24. I have a events script that works, but it shows current and past events only. I want to be able to show all events by year or past or current events. I need some assistance to modify this script. Any help would be appreciated. <?php /* YOU SHOULD NOT HAVE TO EDIT ANY OF THIS PAGE */ require('config.php'); //determine if it a past or present display if (isset($_GET['view']) && ($_GET['view'] == 'past')) { $time = '>'; $opp_time = '<'; $no_events = 'past'; $back_events = 'upcoming'; $view = 'view=past'; $days_shown = 0; $past = ''; $time = $opp_time; } else { $time = '<'; $opp_time = '>'; $no_events = 'upcoming'; $back_events = 'past'; $view = ''; $days_shown = get_option('days_shown'); if ($days_shown == 0) $time = '>'; $past = "&& (TO_DAYS(current) - TO_DAYS(DATE_ADD(NOW(), INTERVAL " . get_option('time_offset') . " HOUR)) " . $opp_time . "= 0) "; } //find the separator for the URL if ($_GET['view'] == 'past') $separator = '&'; else $seprator = '?'; //check that table exists $table_check = mysql_query("select * from " . $prefix . "events limit 0,1"); if ($table_check == true) { ?> <table border="0" cellspacing="0" width="500"> <tr> <td colspan="4">Sort by: <a href="?sort=current<?php echo $separator . $view; ?>">Date</a> / <a href="?sort=event<?php echo $separator . $view; ?>">Event</a> / <a href="?sort=location<?php echo $separator . $view; ?>">Location</a></td> </tr> <?php /* List the upcoming events */ if (isset($_GET['sort'])) { $sort = $_GET['sort']; $query = mysql_query("SELECT * FROM " . $prefix . "events WHERE (TO_DAYS(current) - TO_DAYS(DATE_ADD(NOW(), INTERVAL " . get_option('time_offset') . " HOUR)) " . $time . "= " . $days_shown . ") && (status = 'show') " . $past . "ORDER BY " . $sort . " ASC"); } else $query = mysql_query("SELECT * FROM " . $prefix . "events WHERE (to_DAYS(current) - TO_DAYS(DATE_ADD(NOW(), INTERVAL " . get_option('time_offset') . " HOUR)) " . $time . "= " . $days_shown . ") && (status = 'show') " . $past . "ORDER BY current ASC"); $num = mysql_num_rows($query); $inc = 1; if ($num == 0) echo "<tr>\n\t<td><i>There are no " . $no_events . " events.</i></td>\n</tr>"; else { while ($print = mysql_fetch_array($query)) { if ($inc% 2 == 0) echo '<tr>' . "\n"; else echo '<tr bgcolor="#f0f0f0">' . "\n"; //display proper event date $date = date("M d, Y", strtotime($print["current"])); $time = date("g:i A", strtotime($print["current"])); $enddate = date("D M d, Y", strtotime($print["end"])); $endtime = date("g:i A", strtotime($print["end"])); if ($print["current"] != '0000-00-00 00:00:00'){ echo "\t<td width='25%'>$date"; if (!preg_match('/00\:00\:00/', $print["current"])) echo " <br />$time</td>"; } else echo "\t<td> </td>"; echo "\n\t<td><strong>" . $print['event'] . "</strong></td>"; echo "\n\t<td>" . $print['location'] . "</td></tr>"; if ($inc% 2 == 0) echo "\n" . '<tr class="rows">'; else echo "\n" . '<tr bgcolor="#f0f0f0">'; echo "\n\t<td> </td>"; echo "\n\t<td colspan='3'>" . $print['description'] . "</td>\n</tr>"; $inc++; } } echo "\n"; ?> </table> <p><a href="?view=<?php echo $back_events; ?>">View <?php echo $back_events; ?> events</a></p> <?php } else echo '<p style="border: 1px solid #ff8e00; background: #ffe1a9; padding: .4em;">The event organizer has not yet been set up.</p>'; //get single option value function get_option($name) { global $prefix; $find_option = @mysql_query("select option_value from " . $prefix . "options where option_name = '" . $name . "'"); $get_result = @mysql_fetch_object($find_option); return $get_result->option_value; } ?>
×
×
  • 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.