www.webdeveloper.com
Results 1 to 4 of 4

Thread: [HELP]Getting mysql array from database + onclick function

  1. #1

    Question [HELP]Getting mysql array from database + onclick function

    Hello guys, firstly im so sorry if i post in the wrong forum/section, im not sure how i gonna tell you about this problem but at least i'll try..im trying to get content from database..yes its was perfectly when i push the "Next >>" button, but the problem is i don't even get the content i want from database which is $row[app_id] and $row[canvas], btw to let ya know, i didn't get any error even warning by running this code. is it something wrong with the code? here's the code i'll use for my project.

    PHP Code:
    <?php $info mysql_query("SELECT * FROM yu_user where name='".$yuser."'");
    while(
    $row mysql_fetch_array($info)){?>
    <a id="next" 
    onclick='window.open("http://www.facebook.com/dialog/pagetab?app_id=$row[app_id]&display=popup&next=$row[canvas]", "_blank"); return false;' 
    class="g-btn-sm g-btn-act">Next >></a>
    <br />
    <?}?>
    is it because the curly bracket was close earlier? did you guys have any other alternative? btw it can be done if i just echo the content

    PHP Code:
     <?php $info mysql_query("SELECT * FROM yu_user where name='".$yuser."'");
    while(
    $row mysql_fetch_array($info)){
    echo 
    "app id is $row[app_id]";
    echo 
    "canvas is $row[canvas_url]";
    }
    ?>
    Freeze - Fixways.Net

  2. #2
    Join Date
    Apr 2010
    Posts
    227
    Make it easy on yourself.

    PHP Code:

    $connect 
    mysql_connect($hostname$username$password) or trigger_error(mysql_error(),E_USER_ERROR);

    mysql_select_db($database$connect);
    $query "SELECT * FROM yu_user where name='$yuser'";
    $info mysql_query($query$connect) or die  (mysql_error()."Error while selecting user details"); 

  3. #3
    Join Date
    Jul 2012
    Location
    Vancouver
    Posts
    61
    The problem is your out of php when you're trying to post the data.

    onclick='window.open("http://www.facebook.com/dialog/pagetab?app_id=$row[app_id]&display=popup&next=$row[canvas]", "_blank"); return false;'

    your $row[app_id] and $row[canvas] are printed as exactly that.

    Try this.
    PHP Code:

    onclick='window.open("http://www.facebook.com/dialog/pagetab?app_id=<?=$row["app_id"]?>&display=popup&next=<?=$row["canvas"]?>", "_blank"); return false;'

  4. #4
    thanks for your help guys but i already got it fix. i said echo is ok. but i dont know why i dont use it either..so here the working code if anyone need it
    PHP Code:
     <?php $info mysql_query("SELECT * FROM yu_user where name='".$yuser."'");
    while(
    $row mysql_fetch_array($info)){
    echo 
    "<a id=\"next\" onclick='window.open(\"http://www.facebook.com/dialog/pagetab?app_id=$row[app_id]&display=popup&next=$row[canvas]/\", \"_blank\"); return false;' class=\"g-btn-sm g-btn-act\">Next >></a><br />";
    }
    ?>

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles