Shadowing Posted December 15, 2011 Share Posted December 15, 2011 I am really confused about how people use $_GET to give a page a link so far what I understand is that $_GET grabs the information from a link So if my link was http://localhost/stargate/users/profile.php?goauld=Sam how do I turn this into viewing Sams profile soon as i type in that link with out having to hit a search button first would really appreciate if someone help me understand this please cause it appears i really need to know how to do this. <?php if(isset($_POST['search'])) { // searches goaulds then displays them $search3 = "SELECT goauld,id FROM users WHERE goauld='".mysql_real_escape_string($_POST['goaulds'])."'"; $search2 = mysql_query($search3) or die(mysql_error()); WHILE($search1 = mysql_fetch_array($search2)){ $grab_goauld = $search1['goauld']; echo '<table width="300" height="5" border="1" align="center">'; echo '<th><center>Goauld Statistics</center></th>'; echo "<tr><td height='340'>$grab_goauld</td></tr>"; } } echo '</table>'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/253195-using-_get/ Share on other sites More sharing options...
ricmetal Posted December 15, 2011 Share Posted December 15, 2011 as far as i know you need to reload the page to get the GET info, using nothing but PHP. maybe JS can do this without hitting any search button but not with php. Quote Link to comment https://forums.phpfreaks.com/topic/253195-using-_get/#findComment-1297998 Share on other sites More sharing options...
Shadowing Posted December 15, 2011 Author Share Posted December 15, 2011 I have this so far im thinking it should be something close to this I type in the link http://localhost/stargate/users/goaulds.php?goauld=baal and it should excute the script filling in baal on GET but it doesnt work <?php $search3 = "SELECT goauld FROM game WHERE goauld='".mysql_real_escape_string($_GET['goauld'])."'"; mysql_query($search3) or die(mysql_error()); $grab_goauld = $search3['goauld']; echo '<table width="300" height="5" border="1" align="center">'; echo '<th><center>Goauld Statistics</center></th>'; echo "<tr><td height='340'>$grab_goauld</td></tr>"; echo '</table>'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/253195-using-_get/#findComment-1298000 Share on other sites More sharing options...
Shadowing Posted December 15, 2011 Author Share Posted December 15, 2011 ROAR!!! yes I figured it out! geez ive been wanting to know how to do this for ever <?php // searches goaulds then displays them $search3 = "SELECT goauld FROM game WHERE goauld='".mysql_real_escape_string($_GET['goauld'])."'"; $search2 = mysql_query($search3) or die(mysql_error()); WHILE($search1 = mysql_fetch_array($search2)){ $grab_goauld = $search1['goauld']; echo '<table width="300" height="5" border="1" align="center">'; echo '<th><center>Goauld Statistics</center></th>'; echo "<tr><td height='340'>$grab_goauld</td></tr>"; } echo '</table>'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/253195-using-_get/#findComment-1298002 Share on other sites More sharing options...
masterkip Posted December 15, 2011 Share Posted December 15, 2011 <?php header("Content-type:text/html; charset=utf-8"); if(isset($_GET['goauld'])){ $search3 = "SELECT goauld FROM game WHERE goauld='".mysql_real_escape_string($_GET['goauld'])."'"; $result = mysql_query($search3) or die(mysql_error()); while($row_arr = mysql_fetch_assoc($result)){ // use $row_arr, it associative array contents one row from table } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/253195-using-_get/#findComment-1298003 Share on other sites More sharing options...
Shadowing Posted December 15, 2011 Author Share Posted December 15, 2011 Thanks for joining the conversation masterkip not sure what you mean whats with the header and the arr Quote Link to comment https://forums.phpfreaks.com/topic/253195-using-_get/#findComment-1298006 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.