3 Replies Latest reply on Oct 25, 2007 5:54 PM by (Steve_Guluk)

    PHP Question

      What is the php mysql coding so that I can retrieve an item from one column in the database, not the whole row, just one column. Have created a CMS and want to add coding to site design per page. Will use a div class technique as client wants a scroller.

      http://www.urhomefsbo.com/CMS_training/admin/list_art.php - you can add other page information in the CMS by clicking edit, etc.

      Then I would like the ability to add to each page, but one item per column. Want the ability to add coding to designed site, so client can update site page content only.

      http://www.urhomefsbo.com/CMS_training/template.php

      Tracey
        • 1. Re: PHP Question
          Günter Schenk Level 4
          Hi Tracey,

          ----
          What is the php mysql coding so that I can retrieve an item from one column in the database, not the whole row, just one column
          ----

          I hope to get your question right -- you mean something like "SELECT columnname FROM your_table" ?

          -------
          Then I would like the ability to add to each page, but one item per column
          -------

          are you referring to ADDT´s "add record" page now ?

          ------
          Want the ability to add coding to designed site, so client can update site page content only
          ------

          sorry, I fear I don´t get this -- you want to enable your customer to manually code certain PHP stuff, like queries etc ?

          Cheers,
          Günter Schenk
          Adobe Community Expert, Dreamweaver
          • 2. Re: PHP Question
            Level 1
            No, Here is the coding: <br /> <br />?php require_once('../Connections/connCMS.php'); ?&gt; <br /> <br /> <br /> <br />//Create a Database connection <br /> <br /><?php<br /> $connection = mysql_connect("" , "" , "Homefsbo123");<br /> if (!$connection){<br />    die ("Database connection failed: ". mysql_error());<br /> }   <br />?> <br /> <br />//Select a Database to use <br /> <br /><?php<br /> $db_select = mysql_select_db("tracey123", $connCMS);<br />    if (!$db_select){<br />        die ("Database selection failed: ". mysql_error());<br />    }    <br />?> <br /> <br />//Get Item from Database <br /> <br /><?php <br /> $result = mysql_query("SELECT * FROM page_pag", $connCMS); <br /> if (!$result){<br />    die("Database query failed: ". mysql_error());<br /> }   <br />?> <br /> <br />//Use returned data. <br /> <br /><?php<br /> while($col = mysql_fetch_array($result)) {<br /> echo "<p>" , $col[1];<br />}<br /><br />mysql_free_result($result);<br />mysql_close();<br />?> <br /> <br /> <br /> <br />//Close connection. <br /> <br /><?php<br />   mysql_close($connection);<br />?> <br /> <br />Would like to just get the column information to be placed on a page by adding a php code to each page in the website. Don't want to display the whole row. I created the CMS using ADDT, but now need it to work with the web site. Want to add a code to each page. Client would go online and update the record in the list_art.php page adding new content to each column or updating, etc....... I hope this is clear, this is my first php/mysql program? <br /> <br />tracey <br /> <br />tw
            • 3. Re: PHP Question
              Level 1
              Tracy,
              You saw the page that listed the returned results as a series of rows with specific columns... Great but that is not termed a "column" in reference to the source (mySQL) that you are talking about.

              You seem to want to get the results of a single "field" from a specific "table" in the database.

              ADDT can surely do this but you need to also understand what is the index field and poll the DB to return that record and then update or create a new one if you want to modify or add content.

              I would suggest you learn what your database looks like so you can understand what you are working with. Try accessing the DB via PHPmyAdmin or even look at the test area when you create a recordset.

              What's a recordset you may ask? You need to figure that one out before you can proceed much further.

              Create a new page, tied to the same DB and use the DW "add recordset" server behaviour. From a basic SELECT * from TABLE_FIELD you can use the test button to see the results.

              After you get the basics down, and understand your database (DB) and it's fields you can them begin to understand what it takes to target to populate a specific field or as you have wrote "column".

              ADDT has lots of cool extensions to make what you are asking accomplished quite easily. But you need to learn and understand your index field also before moving much further. The index field as I understand or can explain is a "unique" identifier so that you have no SQL collisions. Or in simpler terms a unique ID for each record.

              I'll stop here so that I do not assume you know more or less than we can deduce from your post and you can post back more information in specifics as to what you need help with.

              Cheers,

              Steve