I am looking out for some kind of short code where i should not be repeating the column names
in database and it should directly be inserted with respective column name
index to array value
. Below i have uploaded the image for understanding.
Use mysql_fetch_assoc()
rather than mysql_fetch_row()
and the array will be associative (using the column names as the key) rather than numeric.
$query = mysql_query("SELECT * FROM users_table WHERE User_ID = 1");
while ($r1 = mysql_fetch_assoc($query))
{
echo $r1['User_ID'] . ': ' . $r1['First_Name'] . ' ' . $r1['Last_Name'] . '<br />';
}
Check this:
$query = mysql_query( "SELECT * FROM users_table WHERE user_id=1;" );
$row = mysql_fetch_array( $query );
print_r( $row );
more about mysql_fetch_array on php.net
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.