whizzykid Posted June 4, 2009 Share Posted June 4, 2009 Hi i have this code but dont knw how to make it select each row in the database. mysql_select_db($database_profiles, $profiles); $query_Recordset2 = "SELECT * FROM biodata"; $Recordset2 = mysql_query($query_Recordset2, $profiles) or die(mysql_error()); $row_Recordset2 = mysql_fetch_assoc($Recordset2); $totalRows_Recordset2 = mysql_num_rows($Recordset2); Quote Link to comment https://forums.phpfreaks.com/topic/160872-help-needed/ Share on other sites More sharing options...
Ken2k7 Posted June 4, 2009 Share Posted June 4, 2009 Use a while loop with mysql_fetch_assoc or mysql_fetch_array. As such - <?php while ($row = mysql_fetch_assoc($Recordset2)) { // your code here } So instead of calling the function once like you have up there, the while loop will keep calling the function to retrieve more rows until there are none left, in which case, the while loop stops. Quote Link to comment https://forums.phpfreaks.com/topic/160872-help-needed/#findComment-848996 Share on other sites More sharing options...
whizzykid Posted June 4, 2009 Author Share Posted June 4, 2009 Thanks when i used that it gave this error. Undefined variable: row_Recordset2 Quote Link to comment https://forums.phpfreaks.com/topic/160872-help-needed/#findComment-849003 Share on other sites More sharing options...
Ken2k7 Posted June 4, 2009 Share Posted June 4, 2009 Forget that. It works like this - <?php while ($row = mysql_fetch_assoc($Recordset2)) { $column1_data = $row['column1_name']; } Of course your replace those with the correct names. Get it? Quote Link to comment https://forums.phpfreaks.com/topic/160872-help-needed/#findComment-849006 Share on other sites More sharing options...
whizzykid Posted June 4, 2009 Author Share Posted June 4, 2009 Hi thanks it works but it displays a default value of 'L' Quote Link to comment https://forums.phpfreaks.com/topic/160872-help-needed/#findComment-849016 Share on other sites More sharing options...
whizzykid Posted June 4, 2009 Author Share Posted June 4, 2009 Hi actually it works but displays only the name. Quote Link to comment https://forums.phpfreaks.com/topic/160872-help-needed/#findComment-849018 Share on other sites More sharing options...
BobcatM Posted June 4, 2009 Share Posted June 4, 2009 Post your whole code and lets have a look. Quote Link to comment https://forums.phpfreaks.com/topic/160872-help-needed/#findComment-849020 Share on other sites More sharing options...
Ken2k7 Posted June 4, 2009 Share Posted June 4, 2009 What do you mean? If you want other columns, just do $row['column_name']. I can't write down everything for you. I don't even know what columns you have. Not saying that this is a request forum or anything, because it most certainly is not. Quote Link to comment https://forums.phpfreaks.com/topic/160872-help-needed/#findComment-849021 Share on other sites More sharing options...
whizzykid Posted June 4, 2009 Author Share Posted June 4, 2009 thanks this is the code. mysql_select_db($database_profiles, $profiles); $query_Recordset2 = "SELECT * FROM biodata"; $Recordset2 = mysql_query($query_Recordset2, $profiles) or die(mysql_error()); while ($row = mysql_fetch_assoc($Recordset2)){ $row_Recordset2 = $row ['Name']; } Quote Link to comment https://forums.phpfreaks.com/topic/160872-help-needed/#findComment-849024 Share on other sites More sharing options...
otuatail Posted June 4, 2009 Share Posted June 4, 2009 You need to ask for all the fields that you wnat while ($row = mysql_fetch_assoc($Recordset2)){ $name = $row ['Name']; $'address'= $row ['address']; $Phone= $row [Phone]; $Mobile= $row [Mobile]; // etc } Quote Link to comment https://forums.phpfreaks.com/topic/160872-help-needed/#findComment-849109 Share on other sites More sharing options...
whizzykid Posted June 4, 2009 Author Share Posted June 4, 2009 Hi thanks i hv done tht but shws errors. $query_Recordset2 = "SELECT * FROM biodata"; $Recordset2 = mysql_query($query_Recordset2, $profiles) or die(mysql_error()); while ($row = mysql_fetch_assoc($Recordset2)){ $row_Recordset2 = $row ['Name'] ['Address']; } $totalRows_Recordset2 = mysql_num_rows($Recordset2); form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1"> <table align="center"> <tr valign="baseline"> <td nowrap="nowrap" align="right">Name:</td> <td><?php echo $row_Recordset2['Name']; ?></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right">Address:</td> <td><input type="text" name="Address" value="<?php echo htmlentities($row_Recordset2['Address'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right">Tracking Number:</td> <td><input type="text" name="Tracking_Number" value="<?php echo htmlentities($row_Recordset2['Tracking Number'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right">Phone Number:</td> <td><input type="text" name="Phone_Number" value="<?php echo htmlentities($row_Recordset2['Phone Number'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right">Delivery Address:</td> <td><input type="text" name="Delivery_Address" value="<?php echo htmlentities($row_Recordset2['Delivery Address'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td> </tr> Quote Link to comment https://forums.phpfreaks.com/topic/160872-help-needed/#findComment-849118 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.