unistake Posted July 9, 2009 Share Posted July 9, 2009 Hi all, I am having massive problems over a small issue! On my website I have 3 columns, the user clicks an image on column 1 which retrieves information from a mysql db using PHP also, then the information is displayed in column 2 instantly. - This part works fine. Then in column 2, I have two images that also when clicked on should show different information from a mysql db, however I can not get this second part to work.... any suggestions?! The code ive been using is here http://www.w3schools.com/PHP/php_ajax_database.asp . Thanks Tim Quote Link to comment Share on other sites More sharing options...
xtopolis Posted July 10, 2009 Share Posted July 10, 2009 I suggest you show us your relevant code and describe specifically which part doesn't work. Quote Link to comment Share on other sites More sharing options...
seventheyejosh Posted July 10, 2009 Share Posted July 10, 2009 A link to your site? the code? FF's error console??? Oh i guess i could use my crystal ball here :\ Quote Link to comment Share on other sites More sharing options...
unistake Posted July 10, 2009 Author Share Posted July 10, 2009 ok I get your point! Thought it would be easier for you just to see what code I was dealing with than put it in this thread.. In the getuser.php code, I have tried to include two buttons that when clicked I would like to show some more information in the 'right' div tag shown in index.html. Any help will be appreciated thanks.. Tim index.html <head> <link href="style.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="selectuser.js"></script> </head> <body> <div id="container"> <div id="left"> <p>click on this bookmaker image.</p> <p><a href="http://www.bet365.com/" target="_blank"><img src="flower1.png" width="200" height="60" name="flower1" onClick="showUser(this.name)"/></a></p> <p><img src="bet1128.png" width="200" height="60" name="bet1128" onClick="showBookie(this.name)" /> </p> </div> <div id="right">this information will depend on the image clicked in the 2nd column (txtHint)</div> <p>Content for id "container" Goes Here </p> <p><div id="txtHint"><b>Person info will be listed here.</b></div></p> </div> </body> selectuser.js // JavaScript Document var xmlhttp; function showUser(str) { xmlhttp=GetXmlHttpObject(); if (xmlhttp==null) { alert ("Browser does not support HTTP Request"); return; } var url="getuser.php"; url=url+"?q="+str; url=url+"&sid="+Math.random(); xmlhttp.onreadystatechange=stateChanged; xmlhttp.open("GET",url,true); xmlhttp.send(null); } function stateChanged() { if (xmlhttp.readyState==4) { document.getElementById("txtHint").innerHTML=xmlhttp.responseText; } } function GetXmlHttpObject() { if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari return new XMLHttpRequest(); } if (window.ActiveXObject) { // code for IE6, IE5 return new ActiveXObject("Microsoft.XMLHTTP"); } return null; } getuser.php <?php $q=$_GET["q"]; $con = mysql_connect('localhost', 'admin', 'password'); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("database123", $con); $sql="SELECT * FROM database WHERE column = '".$q."'"; $result = mysql_query($sql); while($row = mysql_fetch_array($result)) extract($row); { echo "$col1, $col2, $col3, $col4"; } echo " <input type='submit' name='initial' id='button' value='initial' > </label> <label> <input type='submit' name='follow' id='button2' value='followup' >"; mysql_close($con); ?> Quote Link to comment Share on other sites More sharing options...
xtopolis Posted July 11, 2009 Share Posted July 11, 2009 From the code you have supplied, all I can see is the two buttons that you have after clicking the first image. You don't have any code about "doing something else when the second image is clicked". (ie, function showBookie() isn't included in your code) You need to ask a specific question, and supply relevant code. You didn't really ask a question, and the code you have doesn't handle the problem you said you have. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.