Jump to content

Confused with how to retrieve an value from table register in page1.


co.ador

Recommended Posts

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

Link to comment
Share on other sites

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.

 

 

Link to comment
Share on other sites

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>';
    }
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.