co.ador Posted January 12, 2010 Share Posted January 12, 2010 Hi, I want to formulate an if statment for when a store is registered or not. In the stores table I have build an register row. `register` int(11) NOT NULL, then it is going to be equal to 1 for registered and 0 for Not Registered. Now in page1 I am trying to send the value to page2 and formulate an if condition in page2 <?php If (1== $_GET['register']){ echo"Registered" }else{Not Registered}?> That how it would look in page2 Now How can I retrieved the 1 or 0 value in page one from register table in page1 to send it to page2? I am kind of confused help! thank you Quote Link to comment https://forums.phpfreaks.com/topic/188247-confused-with-how-to-retrieve-an-value-from-table-register-in-page1/ Share on other sites More sharing options...
mikesta707 Posted January 12, 2010 Share Posted January 12, 2010 you can, as you put in your post, send it as $_GET[] data. or you can store it in a session. you can also just retrieve the information in page 2 (IDK why you get the info in page1, but if its just to send it to page2, you might as well just get the info in page2) Quote Link to comment https://forums.phpfreaks.com/topic/188247-confused-with-how-to-retrieve-an-value-from-table-register-in-page1/#findComment-993822 Share on other sites More sharing options...
co.ador Posted January 12, 2010 Author Share Posted January 12, 2010 This is my final result for a Registered, Not registered or Register now Script! page1. query= "SELECT register FROM stores" $result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); if (mysql_num_rows($result) > 0) { $row = mysql_fetch_array($result); { echo'<a href="page2.php?register=". $content['register']. "'; }} page2. div id="registered"> Store is: <?php If (1==$_GET['register']){ echo'<span style="color: #0000FF">Registered</span>'; }else{echo'<span style="color:#FF0000">Not Registered!</span>';}?> </div> <div id="registernow"> <?php If (1==$_GET['register']){ '';}else{ echo'<a href="registrationform.php">Register now!</a>'; }?></div> Thank you Milkesta. Quote Link to comment https://forums.phpfreaks.com/topic/188247-confused-with-how-to-retrieve-an-value-from-table-register-in-page1/#findComment-993831 Share on other sites More sharing options...
ignace Posted January 13, 2010 Share Posted January 13, 2010 echo'<a href="page2.php?register=". $content['register']. "'; This is an error and should be: echo "<a href=\"page2.php?register={$content['register']}\">some text</a>"; //or echo '<a href="page2.php?register=' . $content['register'] . '">some text</a>'; //or echo '<a href="page2.php?register=', $content['register'], '">some text</a>'; Your page1 & page2 are actually the same: $query = 'SELECT id, register FROM store'; $result = mysql_query($query, $connection); if (0 !== mysql_num_rows($result)) { while (list($id, $register) = mysql_fetch_array($result, MYSQL_NUM)) { echo 1 === intval($register) ? '<span>Registered</span>' : '<span>Not Registered! <a href="register.php?id=' . intval($id) . '">Register now, it\'s free!</a></span>'; } } Quote Link to comment https://forums.phpfreaks.com/topic/188247-confused-with-how-to-retrieve-an-value-from-table-register-in-page1/#findComment-994106 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.