Jump to content

me1000

Members
  • Posts

    183
  • Joined

  • Last visited

    Never

Posts posted by me1000

  1. ok inside the mysql table the values for PAGE_TYPE are numbers, the if statment converts them all to text
    but I want them to show up in the table

    heres my page again,

    [code]<?
    require_once ("config.php");

    $sql = "SELECT ID, PAGE_TITLE, PAGE_TYPE
    FROM $sTableName
    ORDER BY PAGE_TYPE ASC";

    $sql_result = mysql_query($sql);

    echo "<TABLE BORDER=1>";
    echo "<TR><TH>Page Type </TH><TH>Page Title</TH><TH>Page ID</TH><TH>Edit Page</TH>";
    while ($row = mysql_fetch_array($sql_result)) {


    $page_id = $row["ID"];
    $page_title = $row["PAGE_TITLE"];
    $page_type = $row["PAGE_TYPE"];
    $edit = '<a href ="cms.php?page_id='.$page_id.'">Edit Page</a>';

    // change page type #'s to words

    if ($page_type == 1) {
        echo "Home";
        } else if ($page_type == 2) {
        echo "Series";
        } else if ($page_type == 3) {
        echo "Movies";
        } else if ($page_type == 4) {
        echo "Special";
        } else if ($page_type == 5) {
        echo "Gaming";
        } else {
        echo "unknown";
        }


    echo "<TR><TD>$page_type</TD><TD>$page_title</TD><TD>$page_id</TD><TD>$edit</TD></TR>";
    }
    echo "</TABLE>";

    ?>[/code]



    I think the if statment may need to replace the $page_type variable in the

    echo "<TR><TD>$page_type</TD><TD>$page_title</TD><TD>$page_id</TD><TD>$edit</TD></TR>";

    But im not sure on how to add it to there
  2. ok instead of page type being a number which it is in the database, I want to convert it to text. Im using a if statment for this

    [code]if ($page_type == "1") {
        echo "Home";
        } else if ($page_type == "2") {
        echo "Series";
        } else if ($page_type == "3") {
        echo "Movies";
        } else if ($page_type == "4") {
        echo "Special";
        } else if ($page_type == "5") {
        echo "Gaming";
        } else {
        echo "unknown";
        }[/code]
    now the problem is that im using
    [code]echo "<TR><TD>$page_type</TD><TD>$page_title</TD><TD>$page_id</TD><TD>$edit</TD></TR>";[/code]

    to show the each row. yet that doesnt get me much if you know what I mean.
    how do I do this?? I will probably need to change the variable name in the table.
  3. Ok now I need help with the link to edit

    [code] $edit = 'echo = "<a href ="cms.php?page_id=$page_id">Edit Page</a>" '[/code]

    Im not sure where I should add the quotes and what type of quotes to add, since there is a variable in the URL

    {edit}
    gettin closer
    [code]
    $edit = '<a href ="cms.php?page_id=$page_id">Edit Page</a> '
    [/code]

    but no cigar


    this is my full page if it helps.

    [code]
    <?
    require_once ("config.php");

    $sql = "SELECT ID, PAGE_TITLE, PAGE_TYPE
    FROM $sTableName
    ORDER BY PAGE_TYPE ASC";

    $sql_result = mysql_query($sql);

    echo "<TABLE BORDER=1>";
    echo "<TR><TH>Page Type </TH><TH>Page Title</TH><TH>Page ID</TH><TH>Edit Page</TH>";
    while ($row = mysql_fetch_array($sql_result)) {


    $page_id = $row["ID"];
    $page_title = $row["PAGE_TITLE"];
    $page_type = $row["PAGE_TYPE"];
    $edit = '<a href ="cms.php?page_id='$page_id'">Edit Page</a>';


    echo "<TR><TD>$page_type</TD><TD>$page_title</TD><TD>$page_id</TD><TD>$edit</TD></TR>";
    }
    echo "</TABLE>";

    ?>

    [/code]
  4. thanks for that heres what I came up with, only thing is it doesnt work! lol

    [code]
    <?
    require_once ("config.php");

    $sql = "SELECT ID, PAGE_TITLE, PAGE_TYPE
    FROM $sTableName
    ORDER BY PAGE_TYPE DESC";

    $sql_result = mysql_query($sql);

    echo "<TABLE BORDER=1>";
    echo "<TR><TH>Page Type </TH><TH>Page Title </TH><TH>Page ID </TH>";
    while ($row = mysql_fetch_array($sql_result)) {
    $page_id = $row["ID"];
    $page_title = $row["PAGE_TITLE"];
    $page_type = $row["PAGE_TYPE"];
    echo "<TR><TD>$page_type</TD><TD>$page_title</TD><TD>$page_id</TD></TR>";
    }
    echo "</TABLE>";

    ?>[/code]

    See anything wrong?


    Never Mind I fixed it!!!

    thanks for all your help!
  5. ok I have a my sql table set up as so...

    +---+---------------+---------------+---------+
    | ID | PAGE_TITLE | PAGE_TYTLE | Conent |
    +---+---------------+---------------+---------+
    | 1 | title | type | Conent |
    +---+---------------+---------------+---------+
    | 2 | title2 | type2 | Conent |
    +---+---------------+---------------+---------+

    in doing a mysql query select * from $tablename

    so I want to have a page that sets up a simple table that show the page Title, then the ID next to it in a diffrent column. beside all that I want another collumn that says edit in every row. this will link to page.php?pag_id=2
    where 2 is the ID of the page.

    i am clueless on how to do this. though, i tried to explain it as well as I could I hope you understand.


    how would you do it? Right now i dont have any idea!!!

    Thanks
  6. hello I have been reading the php book, php and mysql web development. im getting into the sql part of it now, im using the wamp server hosted on my computer its just for testing purposes so i do not have to upload all my files.

     

    anyway heres my sql file

    create table customers
    ( customerid int unsigned not null auto_increment primary key,
      name char(30) not null,
      address char(40) not null,
      city char(20) not null,
    );

     

    I have run it through phpMyAdmin and Im getting this error

     

    [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 6

     

    the sql query is

     

     CREATE TABLE customers(
    customerid int unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY ,
    name char( 30 ) NOT NULL ,
    address char( 40 ) NOT NULL ,
    city char( 20 ) NOT NULL ,
    ) 

     

     

    i really have no idea whats wrong with it, im using mysql 5 and i have copied it exactly as the bok has it.

     

     

    {Edit} I also tried the sql comandline not sure if im doing this right if not could you please correct me,

     

    mysql> -h localhost -u bookorama books -p < c:/wamp/www/php/bookorama.sql;
    
    ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
    corresponds to your MySQL server version for the right syntax to use near '-h lo
    calhost -u bookorama books -p < c:/wamp/www/php/bookorama.sql' at line 1
    mysql>

     

    thank you,

    Me1000

×
×
  • 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.