Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

dynaimcally loading only a specific row using a URL query line

Posted on 2004-08-17
5
Medium Priority
?
288 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 200 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
When the s#!t hits the fan, you don’t have time to look up who’s on call, draft emails, call collaborators, or send text messages. An instant chat window is definitely the way to go, especially one like HipChat. HipChat is a true business app. An…
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
This video teaches users how to migrate an existing Wordpress website to a new domain.
Suggested Courses

730 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