SitePoint Sponsor

User Tag List

Results 1 to 16 of 16
  1. #1
    SitePoint Member
    Join Date
    Jul 2007
    Location
    India
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Any problem in PHP ? .... let me try to help you out

    If you have any problem/issues in php do post it here and i will try to help you out ASAP.

    I want this thread to be a usefull resource for the bignners and exp professionals......
    Last edited by tansoft; Jul 30, 2007 at 00:55. Reason: typo mistake

  2. #2
    play of mind Ernie1's Avatar
    Join Date
    Sep 2005
    Posts
    1,252
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    nice try, but we help each other based on user's question.
    you don't have to start a new thread, just answer (if you can) to questions posted to sitepoint forums.
    my mobile portal
    ghiris.ro

  3. #3
    SitePoint Member
    Join Date
    Jul 2007
    Location
    India
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for your advise ..... i just wanted to make things little easier for me so as i will get email notification when any body post any thing on my thread and in this way i can respod to him ASAP.

    I am also active in giving my response on sitepoint forums but its not possible to go through the whole forum at one stress....

  4. #4
    SitePoint Member
    Join Date
    Mar 2007
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hi nice try, and i thought maby u can help me. i try to retrive data from database but i have to display them in two place in the same site with diferent display.first i display all field of record and after some of them in the end of site.i try to make function that retreave all that and after to use it in difrent places with in my site.this is my first time and i dont know how i do that.if u can help me it will be usefull.....thanks

  5. #5
    SitePoint Member
    Join Date
    Jul 2007
    Location
    India
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    When first time you go through the mysql_fetch_array($res) ...... it leavs the pointer at the last record ..... in order to use the same $res for another while loop in the same page you have to move the pointer to the first record which you can do through this mysql_data_seek($res,0) ...... then you can use the same $res for another while loop.....

  6. #6
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Either you can create an array to store the values and and use it whenever you need in the page. But the tansoft's idea maybe more easier.

    What do you say tansoft?
    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5

  7. #7
    SitePoint Member
    Join Date
    Mar 2007
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thank you very much for your replay.i all ready have my database with array that contains news and i want to display only the first new in the top of site with full data and after only the names af news in links with small text to dicribe the news.but i have done that and it works fine ,only with the links i have problem somewhere in my code and all links are like one.but now i try to fix my code with function because i use while two times in the same file and i want to make that more useful and quicly and not so much code.....

  8. #8
    SitePoint Member
    Join Date
    Mar 2007
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    my problem is that i dont know how to use build in functions in there own file and call it in different site.

  9. #9
    SitePoint Member
    Join Date
    Jul 2007
    Location
    India
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by rajug View Post
    Either you can create an array to store the values and and use it whenever you need in the page. But the tansoft's idea maybe more easier.

    What do you say tansoft?
    Yeah you are right ... making an array is also an option for this ..... but that will make some burden on the server due to an extra array to process

  10. #10
    SitePoint Member
    Join Date
    Jul 2007
    Location
    India
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by tatoo View Post
    my problem is that i dont know how to use build in functions in there own file and call it in different site.
    sorry didn't understand what you mean .....if you can send the code then may be we can help you out....

  11. #11
    SitePoint Member
    Join Date
    Mar 2007
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <link rel="stylesheet" type="text/css" href="style.css" />
    <title>ttttt</title>
    <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
    </head>
    <body>

    <?php
    include 'dbcon.inc.php';
    $news = mysql_query('SELECT id, title, text, body, date, photo FROM news WHERE id ='.$_GET['id'].' ORDER BY date DESC LIMIT 0,1');
    if (!$news) {
    exit ('<p>Error retrieven news from database!<br/>'.'Error:'. mysql_error().'</p>');
    }
    while ($new = mysql_fetch_array($news)) {
    $id = $new['id'];
    $title = htmlspecialchars($new['title']);
    $text = htmlspecialchars($new['text']);
    $body = htmlspecialchars($new['body']);
    $date =$new['date'];
    $photo=$new['photo'];

    echo ("<h1>$title</h1>" ."<p>$text</p>"."<p>$body</p>"."$date");
    }

    ?>
    <img scr="image.php" height=100 width=100 alt="">
    <hr />

    <?php
    $news = mysql_query('SELECT id, title, text FROM news');
    if (!$news) {
    exit ('<p>Error retrieven news from database!<br/>'.'Error:'. mysql_error().'</p>');
    }
    while ($new = mysql_fetch_array($news)) {
    $id = $new['id'];
    $title = htmlspecialchars($new['title']);
    $text = htmlspecialchars($new['text']);
    echo ("<h1><a href='" . $body."'>" .$title."</a></h1>"."<p>$text</p>");
    }
    ?>
    <p><a href="index.php">home</a></p>
    </body>
    </html>




    i hope u understand something from this...............thank u again for u help

  12. #12
    SitePoint Member
    Join Date
    Jul 2007
    Location
    India
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by tatoo View Post
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <link rel="stylesheet" type="text/css" href="style.css" />
    <title>ttttt</title>
    <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
    </head>
    <body>

    <?php
    include 'dbcon.inc.php';
    $news = mysql_query('SELECT id, title, text, body, date, photo FROM news WHERE id ='.$_GET['id'].' ORDER BY date DESC LIMIT 0,1');
    if (!$news) {
    exit ('<p>Error retrieven news from database!<br/>'.'Error:'. mysql_error().'</p>');
    }
    while ($new = mysql_fetch_array($news)) {
    $id = $new['id'];
    $title = htmlspecialchars($new['title']);
    $text = htmlspecialchars($new['text']);
    $body = htmlspecialchars($new['body']);
    $date =$new['date'];
    $photo=$new['photo'];

    echo ("<h1>$title</h1>" ."<p>$text</p>"."<p>$body</p>"."$date");
    }

    ?>
    <img scr="image.php" height=100 width=100 alt="">
    <hr />

    <?php
    $news = mysql_query('SELECT id, title, text FROM news');
    if (!$news) {
    exit ('<p>Error retrieven news from database!<br/>'.'Error:'. mysql_error().'</p>');
    }
    while ($new = mysql_fetch_array($news)) {
    $id = $new['id'];
    $title = htmlspecialchars($new['title']);
    $text = htmlspecialchars($new['text']);
    echo ("<h1><a href='" . $body."'>" .$title."</a></h1>"."<p>$text</p>");
    }
    ?>
    <p><a href="index.php">home</a></p>
    </body>
    </html>




    i hope u understand something from this...............thank u again for u help
    What you want in this ????

  13. #13
    SitePoint Member
    Join Date
    Mar 2007
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i want function for while in different file or in the top of this and only to call it when i want to display the results,because i use while two times and its more work for the file and maby will be slow also its not the right way like i use it because i still learn and its my first time with php, also if u can help with the links -echo ("<h1><a href='" . $body."'>" .$title."</a></h1>"."<p>$text</p>");- i want to open the news by id and this is worg because when u try to open the one link of then.... all are like one...............

  14. #14
    SitePoint Member
    Join Date
    Jul 2007
    Location
    India
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    use this .......

    echo ("<h1><a href='?id=". $id."'>" .$title."</a></h1>"."<p>$text</p>");

  15. #15
    SitePoint Member
    Join Date
    Mar 2007
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thank u very much for that..........sory if i distract u ..............have a nice day

  16. #16
    SitePoint Member
    Join Date
    Jul 2007
    Location
    India
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You're welcome


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •