Jump to content

vbracknell

New Members
  • Posts

    9
  • Joined

  • Last visited

    Never

Everything posted by vbracknell

  1. Your code was perfect, except for one typo I had left in: $result = mysql_query($query); should have been $res = mysql_query($query); because that's what list calls: list ($id, $ntype, $newspaper, $circ, $city, $web, $email, $phone, $fax, $county, $member) = mysql_fetch_row($res);  I used your code, and got an error at line 19 (the list code) and then it was easy to spot. Thanks again, so much!!!! Must.get.sleep. Victoria
  2. The index page works fine, and when I click on a newspaper name that has no website (ex. id-3) it returns the correct url: http://www.mspress.org/newspapers/item.php?id=3 but the page shows the following error: Parse error: parse error in /home/httpd/vhosts/mspress.org/httpdocs/newspapers/item.php on line 33
  3. Well, I really thought I could figure the rest out, but I was wrong. With your help, I made the changes to the fields, and here's the new index.php file. In advance, thank you for your time! I've been going through books all night! Victoria <?php include("header.php"); include("links.php"); $db = mysql_connect("localhost", "user", "pass" ); mysql_select_db("database",$db); $sql = "SELECT id, ntype, newspaper, circ, city, web, email, phone, fax, county, member, mcan FROM newspapers ORDER BY city"; $res = mysql_query($sql) or die(mysql_error()); //Table header echo "<table border=0 cellspacing=5 cellpadding=0><tr><td><b>Type</b></td><td><b>Newspaper</b></td><td><b>Circ.</b></td><td><b>City</b></td><td><b>Website</b></td><td><b>E-mail</b></td><td><b>Phone</b></td><td><b>Fax</b></td><td><b>County<b></td><td><b>Member</td><td><b>MCAN</td></tr>"; //Fetch and print all records while (list ($id, $ntype, $newspaper, $circ, $city, $web, $email, $phone, $fax, $county, $member, $mcan) = mysql_fetch_row($res))  { // if has website, use it, else use item.php $url = $web ? 'http://'.$web : "item.php?id=$id"; echo "<tr><td>$ntype</td><td nowrap><a href='$url'>$newspaper</a></td><td nowrap>$circ</td><td nowrap>$city</td><td nowrap>$web</td><td>$email</td><td nowrap>$phone</td><td nowrap>$fax</td><td nowrap>$county</td><td nowrap>$member</td><td>$mcan</td></tr>";  } echo "</table>"; include("links.php"); ?> That part works fine, the name of the newspaper has a link to either the website or the link to item.php. I thought I had a decent understanding of how to make item.php work, but I was wrong: item.php <?php $db = mysql_connect("localhost", "user", "pass" ); mysql_select_db("database",$db); if (isset($_GET['id'])) {     if (!is_numeric($_GET['id'])) {         die('You are trying to use an invalid link');     }     else {         $id = $_GET['id'];     } } $query = "SELECT id, ntype, newspaper, circ, city, web, email, phone, fax, county, member FROM newspapers WHERE id=$id"; $result = mysql_query($query); echo "<table border=0 cellspacing=0 cellpadding=0>\n"; while ($myrow = mysql_fetch_row($result)) { //Table header echo "<table border=0 cellspacing=5 cellpadding=0><tr><td><b>Type</b></td><td><b>Newspaper</b></td><td><b>Circ.</b></td><td><b>City</b></td><td><b>Website</b></td><td><b>E-mail</b></td><td><b>Phone</b></td><td><b>Fax</b></td><td><b>County<b></td><td><b>Member</td><td></tr>"; //Print record while (list ($id, $ntype, $newspaper, $circ, $city, $web, $email, $phone, $fax, $county, $member) = mysql_fetch_row($res))  echo "<tr><td>$ntype</td><td>$newspaper</td><td>$circ</td><td>$city</td><td>$web</td><td>$email</td><td>$phone</td><td>$fax</td><td>$county</td><td>$member</td></tr></table>";  ?>
  4. Thank you so much! I'll try that! Victoria
  5. I'm sorry, I wasn't very clear, was I? The table has the following structure. The 'newspaper' field is clickable - has the name of the newspaper name and link in it if they have a website, otherwise it's just the name. id  tinyint(4)        NType  varchar(6)   Newspaper  varchar(125)       Circ  bigint(11) UNSIGNED       Address  varchar(20)       City  varchar(20)       State  char(2)       Zip  varchar(10)       Phone  varchar(20)       Fax  varchar(20)       Website  varchar(100) <-- sort of redundant   Email  varchar(100)     County  varchar(15)   Member  varchar(20)     MCAN  char(2)     MDAN  char(2)  
  6. yes to both questions The first field is the id - key field, set to autoincrement. Yes, I do have a URL field, I just didn't display it on the index page.
  7. I'm trying to get a list to return information when it's clicked on. Index.php returns the list of all newspapers. That part works fine. I need to set something up so that when the user clicks on the name of a newspaper that does not have a website, it takes them to another "mini-page."  Can anyone point me in the right direction? I've just bought two new php/mysql books, so I'll be deep in that, but if anyone can point me in the right direction I'd really appreciate it! Victoria I was thinking I would have to change the field newspapername to something like: a href="http://www.mspress.org/newspapers/item.php?id=1">newspaper</a but I am not positive I think thinking along the right lines here. index.php: [code]<?php $db = mysql_connect("localhost", "database", "password" ); mysql_select_db("tablename",$db); $result = mysql_query("SELECT * FROM newspapers WHERE 1 ORDER BY City ASC",$db); echo "<table border=0 cellspacing=5 cellpadding=0><font size='2'>\n"; echo "<tr><td>Type</td><td>Newspaper</td><td>Circ.</td><td>City</td><td>Phone</td><td>Fax</td><td>E-Mail</td><td>County</td><td>Membership</td><td>MCAN</td></tr></tr>\n"; while ($myrow = mysql_fetch_row($result)) {       printf("<tr><td nowrap>%s</td><td nowrap>%s</td><td nowrap>%s</td><td nowrap>%s</td><td nowrap>%s</td><td nowrap>%s</td><td nowrap>%s</td><td nowrap>%s</td><td nowrap>%s</td><td nowrap>%s</td>\n",       $myrow[1], $myrow[2], $myrow[3], $myrow[5], $myrow[8], $myrow[9], $myrow[11], $myrow[12], $myrow[13], $myrow[14]); } echo "</font></table>\n"; ?>[/code] item.php: [code]<?php $db = mysql_connect("localhost", "mydatabase", "mypassword" ); mysql_select_db("tablename",$db); **/I know this isn't right $result = mysql_query("SELECT *  FROM `newspapers` WHERE `Newspaper` LIKE 'Amory Advertiser'",$db); echo "<table border=0 cellspacing=5 cellpadding=0>\n"; while ($myrow = mysql_fetch_row($result)) {       printf("<tr>                   <td>Type:</td>                     <td>%s</td>                   </tr>                   <tr>                     <td>Newspaper:</td>                     <td>%s</td>                   </tr>                   <tr>                     <td>Circulation:</td>                     <td>%s</td>                   </tr>                   <tr>                     <td>Address:</td>                     <td>%s</td>                   </tr>                   <tr>                     <td>City:</td>                     <td>%s</td>                   </tr>                   <tr>                     <td>State:</td>                     <td>%s</td>                   </tr>                   <tr>                     <td>Zip:</td>                     <td>%s</td>                   </tr>                   <tr>                     <td>Phone:</td>                     <td>%s</td>                   </tr>                   <tr>                     <td>Fax:</td>                     <td>%s</td>                   </tr>                   <tr>                     <td>Website:</td>                     <td>%s</td>                   </tr>                   <tr>                     <td>E-mail:</td>                     <td>%s</td>                   </tr>                   <tr>                     <td>County:</td>                     <td>%s</td>                   </tr>                   <tr>                     <td>Membership:</td>                     <td>%s</td>                   </tr>                   <tr>                     <td>MCAN/MDAN:</td>                     <td>%s</td>                   </tr>\n", $myrow[1], $myrow[2], $myrow[3], $myrow[4],$myrow[5], $myrow[6],$myrow[7],$myrow[8], $myrow[9], $myrow[10],$myrow[11], $myrow[12], $myrow[13], $myrow[14]); } echo "</font></table>\n"; ?>[/code] MOD edit: code tags added
  8. I'm sorry! this is the code I am using for index.php which returns the list of all newspapers. It works fine, but I need to set something up so that when the user clicks on the name of a newspaper that does not have a website, it takes them to another "mini-page."  Thanks so much for looking at it! I was thinking I would have to change the field newspapername to something like: a href="http://www.mspress.org/newspapers/item.php?id=1">newspaper</a but I am not positive I think thinking along the right lines here. index.php: <?php $db = mysql_connect("localhost", "database", "password" ); mysql_select_db("tablename",$db); $result = mysql_query("SELECT * FROM newspapers WHERE 1 ORDER BY City ASC",$db); echo "<table border=0 cellspacing=5 cellpadding=0><font size='2'>\n"; echo "<tr><td><b>Type</b></td><td><b>Newspaper</b></td><td><b>Circ.</b></td><td><b>City</b></td><td><b>Phone</b></td><td><b>Fax</b></td><td><b>E-Mail<b></td><td><b>County<b></td><td><b>Membership</td><td><b>MCAN</td></tr></tr>\n"; while ($myrow = mysql_fetch_row($result)) { printf("<tr><td nowrap>%s</td><td nowrap>%s</td><td nowrap>%s</td><td nowrap>%s</td><td nowrap>%s</td><td nowrap>%s</td><td nowrap>%s</td><td nowrap>%s</td><td nowrap>%s</td><td nowrap>%s</td>\n", $myrow[1], $myrow[2], $myrow[3], $myrow[5], $myrow[8], $myrow[9], $myrow[11], $myrow[12], $myrow[13], $myrow[14]); } echo "</font></table>\n"; ?> item.php: <?php $db = mysql_connect("localhost", "mydatabase", "mypassword" ); mysql_select_db("tablename",$db); **/I know this isn't right $result = mysql_query("SELECT *  FROM `newspapers` WHERE `Newspaper` LIKE 'Amory Advertiser'",$db); echo "<table border=0 cellspacing=5 cellpadding=0>\n"; while ($myrow = mysql_fetch_row($result)) { printf("<tr> <td>Type:</td> <td>%s</td> </tr> <tr> <td>Newspaper:</td> <td>%s</td> </tr> <tr> <td>Circulation:</td> <td>%s</td> </tr> <tr> <td>Address:</td> <td>%s</td> </tr> <tr> <td>City:</td> <td>%s</td> </tr> <tr> <td>State:</td> <td>%s</td> </tr> <tr> <td>Zip:</td> <td>%s</td> </tr> <tr> <td>Phone:</td> <td>%s</td> </tr> <tr> <td>Fax:</td> <td>%s</td> </tr> <tr> <td>Website:</td> <td>%s</td> </tr> <tr> <td>E-mail:</td> <td>%s</td> </tr> <tr> <td>County:</td> <td>%s</td> </tr> <tr> <td>Membership:</td> <td>%s</td> </tr> <tr> <td>MCAN/MDAN:</td> <td>%s</td> </tr>\n", $myrow[1], $myrow[2], $myrow[3], $myrow[4],$myrow[5], $myrow[6],$myrow[7],$myrow[8], $myrow[9], $myrow[10],$myrow[11], $myrow[12], $myrow[13], $myrow[14]); } echo "</font></table>\n"; ?>
  9. It ought to be easy, but I am not getting it. My ISP is running MySql and PHPMyAdmin, and I have a table set up which holds information about Mississippi newspapers. The main page, http://www.mspress.org/newspapers/index.php just returns a basic list of all newspapers. Ok, easy enough. Right now, clicking on the name of the newspaper will take you to that newspaper's website if they have one. I'd like to set up a mini-page for those newspapers that don't have websites. When the name of the newspaper (for example, the Amory Advertiser) is clicked, it should take them to a mini-page that looks like this. http://www.mspress.org/newspapers/item.php I know the code should be something along the lines of http://www.mspress.org/newspapers/item.php?id=1, but I just don't seem to be able to get these set up right. Any assistance would be greatly appreciated. Victoria
×
×
  • 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.