Solved

dynaimcally loading only a specific row using a URL query line

Posted on 2004-08-17
5
287 Views
Last Modified: 2008-03-06
I am engaged in a dynamic web publishing project and I am trying to get only a specific row in my mysql database to load onto a dynamic template for my dynamic website through the  use of URL query links on my static navigation page.  

My naviagation link looks somthing like this:

<a href="cccc2.php?id=1">

Which is intended to load row # 1 onto my template.

<a href="cccc2.php?id=2"> is supposed to load row #2 and no other rows. What I am getting is just a blank template or stupid excuses.

What I am running is the indigo package on windows 98SE which includes php4 with apache and mysql. The costom template uses the same database that was created for an experimental dixit template.

My template looks somthing like this:

<html><head>

<title>CCCC - Rural New Yorks Enviromental Watchdogs</title>
<?php
$db = mysql_connect("localhost", "root");
mysql_select_db("mydixit",$db);
$id = $_GET['id'];
?>
</head><body background="img/woven.gif">
<p>
<div align="center">
  <table border="0" width="100%">
    <tr>
      <td width="100%">
        <p align="center"><font class="TimesRoman24" color="#000000" face="Times New Roman" size="5"><b><i>
        <p class="titre">
        <!--- Title PHP Begins --->
               <?php
                     $db = mysql_connect("localhost", "root");
                      mysql_select_db("mydixit",$db);
                      $id = $_GET['id'];
                      $sql = "SELECT title
                              WHERE 'id'=$id
                              AND $id = $_GET['id']
                              FROM dixit_pages"  
                  $result = mysql_query("SELECT title FROM dixit_pages,$db);
                  echo "<table border=0 td=100%>\n";
                  printf("%s\n",
                  $myrow["title"]);
                  echo "</table>\n";
                  ?>
        <!--- Title PHP Ends --->
      </p></font></td>
    </tr>
  </table>
</div>
<div align="left">
  <table border="0" width="39%">
    <tr>
      <td width="33%"><font class="TimesRoman10" color="#000000" face="Times New Roman"><i>updated:
        </i></font></td>

      <td width="67%"><font class="TimesRoman10" color="#000000" face="Times New Roman"><i>


<!--- Date Posted --->

               <?php

               $db = mysql_connect("localhost", "root");
               mysql_select_db("mydixit",$db);
               $id = $_GET['id'];

               $result = mysql_query(" WHERE id=$id SELECT DATE FROM dixit_pages",$db);

                 echo "<table border=1 td=100%>\n";

                 printf("%s\n",
                  $myrow["DATE"]);


                  echo "</table>\n";

                   ?>




<!--- startDate Ends! --->




</i></font></td>
    </tr>
  </table>
</div>
<p>&nbsp;</p>
<table border="0" width="113%">
  <tr>
    <td width="100%">
      <p align="center"><p class="texte">

<!--- PHP Content Begins! --->
     
     
     
               <?php

               $db = mysql_connect("localhost", "root");
               mysql_select_db("mydixit",$db);
               $id = $_GET['id'];

                $result = mysql_query("WHERE id = $id SELECT content FROM dixit_pages",$db);

 
                  echo "<table border=0 td=100%>\n";
                 

                 printf("%s\n", $myrow["content"]);


                  echo "</table>\n";

                 ?>
     
     
<!--- PHP Content Ends! --->  
     
      </p></td>
  </tr>
</table>
<p align="left"><font class="TimesRoman10" color="#000000" face="Times New Roman" size="2">
<a href="http://www.homestead.com/concernedcitizens/index.html" target="_self">
<i>Concerned Citizens of Cattaragus County </i></a>

If anyone could help me with this it would be greatly appreciated.



0
Comment
Question by:shoeboxxpc
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 1

Accepted Solution

by:
C7Swill earned 50 total points
ID: 11827802
shoeboxx,

your problem is the way you are getting your info from the database

A well formed php mysql database query would look like this.

$sql = mysql_query("SELECT what FROM database WHERE field='$_GET[variable]'")  
$result = mysql_fetch_array($sql);

in your case:

$sql = mysql_query("SELECT title, date, content FROM dixit_pages WHERE id='$id'")  
$result = mysql_fetch_array($sql);

You can then reference the title by

echo $result['title'];
echo $result['date'];
echo $result['content'];

title, content and date must be columns in your mysql database.


Try this code:

// Start Code
// Connect
$db = mysql_connect("localhost", "root");
mysql_select_db("mydixit",$db);
// Convert Get Id
$id = $_GET['id'];
// Select Page
$sql = mysql_query("SELECT title, date, content FROM dixit_pages WHERE id='$id'");
// Put into array
$result = mysql_fetch_array($sql);
// Echo
echo $result['title'];
echo $result['date'];
echo $result['content'];
// End Code


--Sean
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Learn by example how to specify CSS selectors for Selenium WebDriver test automation software.
An enjoyable and seamless user experience can go a long way on an eCommerce site. While a cohesive layout and engaging copy play roles in creating a positive user experience, some sites neglect aspects that seem marginal but in actuality prove very …
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question