Getting info from DB
Posted: Mon Sep 01, 2014 11:11 pm
hello,
i want to know if i am doing this correctly. i am pulling info out of my database but i am pretty sure i am using a script thats made for if i was posting results into a table
is there a better way of doing this.. there will obviously only be 1 email address
for example is there a way i can get this variable $tablesqlrow2['orderemail']; without going through all that trouble. because it will only work in that while().. is there a way i can pull information out of a db at anytime of my page by assigning $tablesqlrow2 to a code so i can pull it out wherever in my code?
thank you
i want to know if i am doing this correctly. i am pulling info out of my database but i am pretty sure i am using a script thats made for if i was posting results into a table
Code: Select all
<?
$tablesql2 = "SELECT * FROM `orders` WHERE ordernumber ='$ordernumber'";
$tablesqlresult2 = mysql_query($tablesql2) or die(mysql_error());
$num_rows2 = mysql_num_rows($tablesqlresult2);
if ( 0==$num_rows2 ) {
echo " <tr>
<th class=tg2-ygl1>no email listed</th>
</tr></table>";
}
else {
while($tablesqlrow2 = mysql_fetch_array($tablesqlresult2)) {
?>
<tr>
<td class="tg2-031e"><input type="text" id="shippingemail" name="shipping_email" value="<?php echo $tablesqlrow2['orderemail']; ?>"></td>
</tr>
<tr>
<td class="tg2-3rvq"><input type="submit" value="Update E-Mail Address"></td>
</tr>
</form>
<?php
}
}
?>
for example is there a way i can get this variable $tablesqlrow2['orderemail']; without going through all that trouble. because it will only work in that while().. is there a way i can pull information out of a db at anytime of my page by assigning $tablesqlrow2 to a code so i can pull it out wherever in my code?
thank you