Jump to content

[SOLVED] odbc_num_rows problem.


dh526

Recommended Posts

Hi everyone :)

 

I have a problem (of which I seem to have lots ...) involving odbc_num_rows().

 

What I want to do is look up tblCard and see if there is any records with the username equal to that of $username stored in a cookie. Then if there is records show a table to edit those details, if not show a table to add some details.

 

The problem I have is how to do the if statement...

 

my 1st thought was to do

 

if (odbc_num_rows($rs) > 0) then Show table edit card

else show add card table.

 

I dont really know if i've missed a step or am using odbc_num_rows incorrectly :S

 

here is my code :

<?php 

$conn=odbc_connect('db09','','');

$sql="SELECT username FROM tblCard WHERE username='$username'";

$rs=odbc_exec($conn, $sql);

if ((odbc_num_rows($sql) > 0))
{ 
echo "<H1> add a card! $username </h1><br><div><a href='address.php'>| Add/Edit Address Details | </a> <a href='card.php'> Add/Edit Card Details |</a> <a href='signedin.php'> Edit My Details |</a><br><br><br><a href='card.php'> Add card |</a> <a href='editcard.php'>Edit card</a><br><br><p>	--Please note - All fields must be entered-- </p><br><br><form action='addcard.php' method='POST' onsubmit='return validate(this);'><table border = 0><tr><td>Name :</td> <td> <input type='text' name='cname' /></td></tr><tr><td>Number: </td> <td> <input type='text' name='num' /></td></tr><tr><td>Type: </td> <td> <input type='text' name='type' /> </td></tr><tr><td>Expiry date: </td> <td> <input type='text' name='ex' /> </td> <td>Please enter in the form of LL99 9LL</td></tr><tr><td>security code: </td> <td> <input type='text' name='sec' /> </td> <td>3 digits on signature strip</td></tr><tr><td></td></tr><tr><td> <input type='submit' value='Add card'></td> <td>  </td></tr></form></table>";
}
else
{
echo "<h1>Edit your Card details, $username</a></h1><br><div><a href='editcard.php'>| Add/Edit Card Details | </a> <a href='card.php'> Add/Edit Card Details |</a> <a href='signedin.php'> Edit My Details |</a><br><br><br><a href='card.php'> Add Card |</a> <a href='editaddress.php'>Edit Address</a><br><br><p>--Please note - All fields must be entered : if you wish to change one line of your address, please enter the full addresss again--</p><br><br><form action='editcard1.php' method='POST' onsubmit='return validate(this);'><table border = 0><tr><td>Name :</td> <td> <input type='text' name='cname' /></td></tr><tr><td>Number: </td> <td> <input type='text' name='num' /></td></tr><tr><td>Type: </td> <td> <input type='text' name='type' /> </td> </tr><tr><td>Expirydate: </td> <td> <input type='text' name='ex' /> </td> <td>Please enter in the form of LL99 9LL</td></tr><tr><td>security code: </td> <td> <input type='text' name='sec' /> </td> <td>3 digits on signature strip</td></tr><tr><td></td></tr><tr><td> <input type='submit' value='Edit card'></td> <td>  </td></tr></form></table>";
}

			?>

 

 

Any help would be much appreciated :) thank you in advance :)

 

 

 

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/159598-solved-odbc_num_rows-problem/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.