Jump to content

yuckysocks

Members
  • Posts

    32
  • Joined

  • Last visited

    Never

Everything posted by yuckysocks

  1. I guess my -REAL- answer is that I don't know how to pull just the piece of data I want out of the array that's produce by the first query. Back to the books I suppose.
  2. Well, <looking at toes> the real answer is I don't know enough about PHP to do otherwise. This is an amalgam of copied and pasted code with my own database names thrown in. Thanks for the tips
  3. Any help would be appreciated. Specifically, the <h4> tag doesn't contain anything when this is run. Thanks! <?php $id = intval($_GET['id']); echo "<div id=\"content\">"; echo "<h3 id=\"title\">Case Study Details</h3>"; $link = mysql_connect('localhost', 'name', 'pw') or die('Could not connect: ' . mysql_error()); mysql_select_db('case_studies') or die('Could not select database'); $query = "SELECT schoolname FROM casestudies WHERE id = $id"; $result = $schoolname; echo "<h4>$schoolname</h4>"; $query = "SELECT * FROM casestudies WHERE id = $id"; $result = mysql_query($query) or die('Query failed: ' . mysql_error()); $row = mysql_fetch_assoc($result); foreach ($row as $fld => $val) { echo "<p class=\"caseresult\"><b>$fld</b> : $val </p>"; } ?>
  4. I can't believe I got such timely help. Thanks so much. (I want to mark this "solved" like I'm supposed to, but can't see the link...)
  5. Ok, I put in the id field which autoincrements. Since the table generates itself, how could I write a link that uses the id number of the database row? I added "id" to the query line, and now it just shows up in the table. I guess what I really need is a deeper understanding of what exactly this script is doing. (It's from php.net) What I really want is for the script to pull the three columns it is right now, PLUS the ID field, but not display all 4 (just show the three it already does, that is, schoolname, schoolcity, and state). Then I want to plug that id in as something like schoolinfo.php?id={$id}, right?
  6. Hi, I have an html table which is drawn from a MySQL table like so: $query = 'SELECT schoolname, schoolcity, state FROM casestudies'; $result = mysql_query($query) or die('Query failed: ' . mysql_error()); // Printing results in HTML echo "<table class=\"sortable\">\n"; echo "<th>School Name</th> <th>School City</th> <th>State</th>"; while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { echo "\t<tr>\n"; foreach ($line as $schoolname) { echo "\t\t<td>$schoolname</td>\n"; } echo "\t</tr>\n"; } echo "</table>\n"; This pulls only three fields from the database for each school (out of ~60)... what I'd like to do is have the schoolname field in the html table be a link to a page which shows -all- of the row from the database. How is the best way to do this? If I change foreach ($line as $schoolname) { echo "\t\t<td>$schoolname</td>\n"; into foreach ($line as $schoolname) { echo "\t\t<td><a href=\"$schoolname.html\"</a></td>\n"; I could just create an .html file for each page, but I want this to happen automatically. I don't know enough about php to know how to start this. Thanks a lot for any help, Alex
  7. Hi, I want to make a simple script that changes a menu's style based on what the active page is. the code I have now is thusly: <?php $currentPage = basename($_SERVER['SCRIPT_NAME']); ?> <ul> <li><a href="index.php" <?php if ($currentPage == 'index.php') {echo 'id="here"';} ?>>Exchange Home</a></li> <li><a href="nechps.php" <?php if ($currentPage == 'nechps.php') {echo 'id="here"';} ?>>Northeast...... I've tried one-line scripts that read either: <?php echo basename($_SERVER['SCRIPT_FILENAME'], '.php'); ?> or <?php echo basename($_SERVER['SCRIPT_NAME']); ?> to define the variable, but both simple scripts return "php.cgi". I know that this means my server is running php via cgi... is there a workaround to gain similar functionality? Alex
×
×
  • 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.